-
-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[mypyc] ... inferred type None; add an annotation
on fully-annotated code
#17216
Labels
bug
mypy got something wrong
Comments
hauntsaninja
pushed a commit
that referenced
this issue
May 21, 2024
…17217) Fixes #17216 During conversion from a standard library AST to the mypy AST, `Var` nodes were being created inside `Argument` nodes without acknowledging the presence of a type annotation, leading to the `Var` node's type as being always set as *inferred*: https://github.com/python/mypy/blob/fb31409b392c5533b25173705d62ed385ee39cfb/mypy/nodes.py#L988 This causes an error at https://github.com/python/mypy/blob/fb31409b392c5533b25173705d62ed385ee39cfb/mypyc/irbuild/expression.py#L161-L164 The fix simply acknowledges any presence of a type annotation, so the type of the relevant `Var` node is no longer considered inferred if an annotation is present.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Bug Report
Possibly related to #7482 and #5423
To Reproduce
Run
mypyc
on the following snippet:Expected Behavior
Successful compilation
Actual Behavior
mypyc doesn't like the annotation
int | str | None
(if you add something unrelated to the union that doesn't exhaust theif...elif
stack, e.g.bytes
, the error goes away). What would be an alternative annotation which could be used here that reflectsint | str | None
, apart fromobject
ortyping.Any
?Your Environment
mypy.ini
(and other config files): NoneThe text was updated successfully, but these errors were encountered: