Bug report
Bug description:
from annotationlib import get_annotations
from _colorize import ThemeSection
get_annotations(ThemeSection) # NameError: name 'ClassVar' is not defined
See the above reproducer and beartype/beartype#656 for more context. The issue here is that the _colorize module (which is imported by other public modules/packages in the stdlib) guards its typing imports (which are used in dataclass field annotations) in an if False: block. This breaks runtime type checkers like beartype that introspect type annotations at runtime.
CPython versions tested on:
3.15
Operating systems tested on:
Linux
Bug report
Bug description:
See the above reproducer and beartype/beartype#656 for more context. The issue here is that the
_colorizemodule (which is imported by other public modules/packages in the stdlib) guards itstypingimports (which are used in dataclass field annotations) in anif False:block. This breaks runtime type checkers like beartype that introspect type annotations at runtime.CPython versions tested on:
3.15
Operating systems tested on:
Linux