Skip to content

False positive [call-arg] with functools.partial and concurrent.futures.Executor.submit #19028

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andrei-korshikov opened this issue May 5, 2025 · 1 comment
Labels
bug mypy got something wrong topic-calls Function calls, *args, **kwargs, defaults

Comments

@andrei-korshikov
Copy link

I get false positive [call-arg] when I apply functools.partial to concurrent.futures.Executor.submit. I see a bunch of opened partial-related issues, but I can't understand if my use case is a duplicate (if it is so—I am sorry for the noise). I've tried to reproduce this without concurrent.futures but got no luck.

To Reproduce

Actual Behavior

Versions 1.10.1 and earlier—no errors (expected behaviour).

Versions 1.11.01.13.0:

main.py:11: error: Missing positional argument "parameter" in call to "submit" of "Executor"  [call-arg]

Versions from 1.14.0 up to the "master branch":

main.py:11: error: Missing positional argument "parameter" in call to "submit" of "Executor"  [call-arg]
main.py:11: error: Too few arguments for "submit" of "Executor"  [call-arg]

Your Environment

I've played in playground with its default settings (i.e. no options were checked) and Python versions 3.12 and 3.13.

@andrei-korshikov andrei-korshikov added the bug mypy got something wrong label May 5, 2025
@sterliakov sterliakov added the topic-calls Function calls, *args, **kwargs, defaults label May 5, 2025
@sterliakov
Copy link
Collaborator

Okay, this is the first time I see this pattern inverted - usually we know the function and apply its args later. functools.partial is supported via a plugin and doesn't handle all corner cases.

In 1.11.0, if I'm not mistaken, we started handling partial more strictly. Before that you were facing essentially a Callable[..., RetType], any arguments would've been accepted in this scenario.

In 1.14.0 we started tracking paramspec binding in partial, but it only works one way - given a callable, we record whether it's paramspec args and/or kwargs are bound in the partial signature. This should be fixable, but fairly non-trivial, we don't have any precedent of backtracking from arguments to callable AFAIC. That explains "too few arguments".

This should be fixable, but may require completely different approach. Perhaps it's possible to reconstruct the arguments from partial and the call together, then check a call as usual? We'll save a bunch of callable transformations, and that should be more reliable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug mypy got something wrong topic-calls Function calls, *args, **kwargs, defaults
Projects
None yet
Development

No branches or pull requests

2 participants