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
{{ message }}
Repository navigation
Regression on validation of manual type annotations to functools.partial between stable version and git #17301
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.
Activity
surrealoatmeal commentedon May 31, 2024
Actually, on further inspection, the current stable release probably doesn't generate any errors because the type given to the annotation is not validated at all.
For example, the
partial[bool]annotation is also considered correct by version 1.10.0: https://mypy-play.net/?mypy=latest&python=3.12&gist=8b38f943d002dc6ce084e8771251e78aSo, 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.
hauntsaninja commentedon Jun 22, 2024
Thanks for testing against latest! If your repo is open source, lmk, I can add it to https://github.com/hauntsaninja/mypy_primer
Fix explicit type for partial (python#17424)