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
This is similar to python/typing#1550, but technically independent as the proposed spec change is about what goes inside Literal[], and this issue is about contexts where mypy should infer literal types, which is not specified precisely.
The text was updated successfully, but these errors were encountered:
This makes unary positive on integers preserve the literal value of the
integer, allowing `var: Literal[1] = +1` to be accepted. Basically I
looked for code handling `__neg__` and added a branch for `__pos__` as
well.
Fixes#16728.
Currently this fails:
main.py:3: error: Incompatible types in assignment (expression has type "int", variable has type "Literal[1]") [assignment]
https://mypy-play.net/?mypy=latest&python=3.10&gist=ca355823e5fdc571fb3efa9c4f0bb764
Pyright allows it; mypy probably should too.
This is similar to python/typing#1550, but technically independent as the proposed spec change is about what goes inside
Literal[]
, and this issue is about contexts where mypy should infer literal types, which is not specified precisely.The text was updated successfully, but these errors were encountered: