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
Bug description
The behavior of Annotated has been changed so that it is allowed at runtime to wrap ClassVar and Final. This change helps avoid friction with other users of annotations; see https://bugs.python.org/issue46491 for context. This change has landed in 3.11 and has been backported to 3.9, 3.10, and typing_extensions. pytype should follow suit in allowing the wrapping in order to allow the friction lifting to happen in practice. The current implementation of Final in pytype errors for this case.
Expected behavior
The above code should type check. Currently ClassVar works, but Final throws an error in the current main code.
Logs
[1/1] check antestFAILED: /home/gregory/Downloads/testcase/pytest/antest/.pytype/pyi/antest.pyi/home/gregory/.venvs/pytype/bin/python -m pytype.single --imports_info /home/gregory/Downloads/testcase/pytest/antest/.pytype/imports/antest.imports --module-name antest -V 3.9 -o /home/gregory/Downloads/testcase/pytest/antest/.pytype/pyi/antest.pyi --analyze-annotated --nofail --quick /home/gregory/Downloads/testcase/pytest/antest/antest.pyFile "/home/gregory/Downloads/testcase/pytest/antest/antest.py", line 21, in C: Invalid type annotation 'Annotated[Final[int], "metadata"]' [invalid-annotation] Invalid use of typing.Final Final may only be used as the outermost type in assignments or variable annotations.File "/home/gregory/Downloads/testcase/pytest/antest/antest.py", line 21, in C: Invalid use of typing.Final [final-error] Final may only be used as the outermost type in assignments or variable annotations.
Bug description
The behavior of
Annotated
has been changed so that it is allowed at runtime to wrapClassVar
andFinal
. This change helps avoid friction with other users of annotations; see https://bugs.python.org/issue46491 for context. This change has landed in 3.11 and has been backported to 3.9, 3.10, andtyping_extensions
. pytype should follow suit in allowing the wrapping in order to allow the friction lifting to happen in practice. The current implementation ofFinal
in pytype errors for this case.Reproduction steps
Expected behavior
The above code should type check. Currently
ClassVar
works, butFinal
throws an error in the currentmain
code.Logs
Additional context
Corresponding issue for dataclasses (incl
InitVar
) is at https://bugs.python.org/issue46511pyright change: microsoft/pyright@8ce7fa6
mypy bug: python/mypy#12061
pyre bug: facebook/pyre-check#577
The text was updated successfully, but these errors were encountered: