-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
dict type incorrectly converted (widened?) to object via TypeVar and overload #16282
Comments
Mypy's behavior here is correct. The value
Mypy's constraint solver uses joins rather than unions, so it widens the type of When applying the solutions for You likely thought that mypy would use "union expansion" for the type of argument The mypy documentation for overloaded call evaluation is a bit vague about how this works. The pyright documentation for overloads is a bit more detailed, so it may help illuminate what's happening here. |
Thanks, I'll read the documents and try to understand. Would you know how to fix the typing of the |
This seems to hit a mypy error, python/mypy#16282, whereby a union input is widened rather than narrowed by the override options - hence the type ignores.
Bug Report
In the snippet below I'd expect the revealed type to be
def () -> typing.Awaitable[builtins.dict]
, notdef () -> typing.Awaitable[builtins.object]
.To Reproduce
https://mypy-play.net/?mypy=master&python=3.12&gist=f596993883d9235e669e38dbe212909e
Actual Behavior
main.py:18: note: Revealed type is "def () -> typing.Awaitable[builtins.object]"
Your Environment
mypy.ini
(and other config files):This may be related to #12385 - closest issue I can find.
The text was updated successfully, but these errors were encountered: