Skip to content

Improve ParamSpec type inference from lambda - #11602

Merged
JukkaL merged 1 commit into
masterfrom
paramspec-lambda
Nov 23, 2021
Merged

JukkaL merged 1 commit into
masterfrom
paramspec-lambda

Conversation

@JukkaL

@JukkaL JukkaL commented Nov 23, 2021

Copy link
Copy Markdown
Collaborator

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
Copy Markdown
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