| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
These are used in the wild and covered by dataclasses unit tests. Several static type checkers support this pattern. Note we adjust one test from ClassVar[ClassVar] to ClassVar[ClassVar[int]] so that it still fails. This is surprising, but not a result of weirdness we're doing in this patch. This is a limitation of the current way runtime type checking works that this case is allowed when bare special forms are allowed. For example, before this patch `ClassVar[Final]` is a valid annotation despite nesting these forms being generally disallowed. Addressing this limitation could be future work.
|
@gvanrossum: Please replace # with GH- in the commit message next time. Thanks! |
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
This is a simple matter of just adding ClassVar to the list of types allowed to be bare before the later call that raises for bare types.
These are used in the wild and covered by dataclasses unit tests.
Several static type checkers support this pattern.
Note we adjust one test from ClassVar[ClassVar] to
ClassVar[ClassVar[int]] so that it still fails. This is surprising, but
not a result of weirdness we're doing in this patch. This is a
limitation of the current way runtime type checking works that this case
is allowed when bare special forms are allowed. For example, before this
patch ClassVar[Final] is a valid runtime annotation despite nesting these
forms being generally disallowed, so it's expected allowing bare ClassVar
makes ClassVar[ClassVar] valid as well.
https://bugs.python.org/issue46553