You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When validating manual type hints to the return of a call to functools.partial, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that the git version asserts that the correct annotation should be partial[partial[T]], where T is the type manually annotated for the functools.partial call.
The stable release does not generate any errors, as expected.
Actual Behavior
However, on the current git build, the following error message is displayed:
error: Incompatible types in assignment (expression has type "partial[partial[str]]", variable has type "partial[str]") [assignment]
error: Argument 1 to "generic" has incompatible type "type[str]"; expected "type[partial[str]]" [arg-type]
If the type annotation is changed to something nonsensical:
mypy now generates an error asserting the type of the expression is of type partial[partial[TYPE GIVEN]]:
main.py:13: error: Incompatible types in assignment (expression has type "partial[partial[bool]]", variable has type "partial[bool]") [assignment]
main.py:13: error: Argument 1 to "generic" has incompatible type "type[str]"; expected "type[partial[bool]]" [arg-type]
So, rather than being a regression, it could be the incomplete and/or buggy implementation of a new check introduced to the codebase after 1.10.0.
I am not sure whether to file a separate bug report or even change the title to reflect my hypothesis though, as they could be unrelated bugs, so I'm leaving it up to the discretion of the maintainers.
Bug Report
When validating manual type hints to the return of a call to
functools.partial
, there has occurred a regression between the latest stable release (1.10.0) and the master branch, in that the git version asserts that the correct annotation should bepartial[partial[T]]
, whereT
is the type manually annotated for thefunctools.partial
call.To Reproduce
TL;DR:
master branch: https://mypy-play.net/?mypy=master&python=3.12&gist=e45e31f06514aabe6a039dfc759e9a3b
1.10.0: https://mypy-play.net/?mypy=latest&python=3.12&gist=e45e31f06514aabe6a039dfc759e9a3b
Consider:
Expected Behavior
For the below definition:
The stable release does not generate any errors, as expected.
Actual Behavior
However, on the current git build, the following error message is displayed:
If the type annotation is changed to something nonsensical:
mypy now generates an error asserting the type of the expression is of type
partial[partial[TYPE GIVEN]]
:Playground for this: https://mypy-play.net/?mypy=master&python=3.12&gist=8b38f943d002dc6ce084e8771251e78a
Your Environment
N/A, reproducible in mypy Playground environment.
Thank you for your hard work maintaining mypy!
The text was updated successfully, but these errors were encountered: