cpython/Lib/test/test_dataclasses
Miss Islington (bot) 00cf7d9fc2
[3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) (#158946)
With string annotations, dataclasses looks up the first name of each
annotation to detect ClassVar, InitVar and KW_ONLY. If that name was a
lazy import that could not be resolved, the lookup raised and the class
could not be created, while the same class works with non-string
annotations.

This resolves lazy imports the way annotationlib does: try to resolve
them, and treat a failure like a missing name.
(cherry picked from commit 0f1d4a79f6)

Co-authored-by: Brittany Reynoso <breynoso@meta.com>
2026-10-09 12:14:47 -07:00
..
__init__.py [3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) (#158946) 2026-10-09 12:14:47 -07:00
_types_proxy.py gh-133956 fix bug where dataclass wouldn't detect ClassVar fields if ClassVar was re-exported from a module other than typing (#140541) 2026-05-03 15:59:18 -07:00
dataclass_lazy_broken.py [3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) (#158946) 2026-10-09 12:14:47 -07:00
dataclass_lazy_str.py [3.15] gh-158936: Resolve lazy imports consistently for dataclass annotations (GH-158939) (#158946) 2026-10-09 12:14:47 -07:00
dataclass_module_1.py
dataclass_module_1_str.py
dataclass_module_2.py
dataclass_module_2_str.py
dataclass_module_3.py gh-133956 fix bug where dataclass wouldn't detect ClassVar fields if ClassVar was re-exported from a module other than typing (#140541) 2026-05-03 15:59:18 -07:00
dataclass_module_3_str.py gh-133956 fix bug where dataclass wouldn't detect ClassVar fields if ClassVar was re-exported from a module other than typing (#140541) 2026-05-03 15:59:18 -07:00
dataclass_module_4.py gh-133956 fix bug where dataclass wouldn't detect ClassVar fields if ClassVar was re-exported from a module other than typing (#140541) 2026-05-03 15:59:18 -07:00
dataclass_module_4_str.py gh-133956 fix bug where dataclass wouldn't detect ClassVar fields if ClassVar was re-exported from a module other than typing (#140541) 2026-05-03 15:59:18 -07:00
dataclass_textanno.py