mirror of
https://github.com/python/cpython
synced 2026-11-06 09:02:40 +03:00
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
|
||
|---|---|---|
| .. | ||
| __init__.py | ||
| _types_proxy.py | ||
| dataclass_lazy_broken.py | ||
| dataclass_lazy_str.py | ||
| dataclass_module_1.py | ||
| dataclass_module_1_str.py | ||
| dataclass_module_2.py | ||
| dataclass_module_2_str.py | ||
| dataclass_module_3.py | ||
| dataclass_module_3_str.py | ||
| dataclass_module_4.py | ||
| dataclass_module_4_str.py | ||
| dataclass_textanno.py | ||