Skip to content

Improve ParamSpec type inference from lambda #11602

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

Merged
merged 1 commit into from
Nov 23, 2021
Merged

Conversation

JukkaL
Copy link
Collaborator

@JukkaL JukkaL commented Nov 23, 2021

If ParamSpec is in the context of a lambda, treat it similar
to Callable[..., Any]. This allows us to infer at least argument
counts and kinds. Types can't be inferred since that would require
"backwards" type inference, which we don't support.

Follow-up to #11594.

If ParamSpec is in the context of a lambda, treat it similar
to `Callable[..., Any]`. This allows us to infer at least argument
counts and kinds. Types can't be inferred since that would require
"backwards" type inference, which we don't support.

Follow-up to #11594.
@github-actions
Copy link
Contributor

Diff from mypy_primer, showing the effect of this PR on open source code:

spark (https://github.com/apache/spark.git)
- python/pyspark/shell.py:49: error: Cannot infer type of lambda  [misc]

tornado (https://github.com/tornadoweb/tornado.git)
- tornado/util.py:55: error: Cannot infer type of lambda

@JukkaL JukkaL merged commit 83e9e3b into master Nov 23, 2021
@JukkaL JukkaL deleted the paramspec-lambda branch November 23, 2021 17:55
tushar-deepsource pushed a commit to DeepSourceCorp/mypy that referenced this pull request Jan 20, 2022
If ParamSpec is in the context of a lambda, treat it similar
to `Callable[..., Any]`. This allows us to infer at least argument
counts and kinds. Types can't be inferred since that would require
"backwards" type inference, which we don't support.

Follow-up to python#11594.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants