Skip to content

Commit

Permalink
fix for namespace issue with dataclasses with from __future__ import …
Browse files Browse the repository at this point in the history
…annotations (#8513)
  • Loading branch information
sydney-runkle committed Jan 8, 2024
1 parent a73e1a9 commit 56d4e92
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pydantic/_internal/_fields.py
Expand Up @@ -264,6 +264,10 @@ def collect_dataclass_fields(
dataclass_fields: dict[str, dataclasses.Field] = cls.__dataclass_fields__
cls_localns = dict(vars(cls)) # this matches get_cls_type_hints_lenient, but all tests pass with `= None` instead

source_module = sys.modules.get(cls.__module__)
if source_module is not None:
types_namespace = {**source_module.__dict__, **(types_namespace or {})}

for ann_name, dataclass_field in dataclass_fields.items():
ann_type = _typing_extra.eval_type_lenient(dataclass_field.type, types_namespace, cls_localns)
if is_classvar(ann_type):
Expand Down

0 comments on commit 56d4e92

Please sign in to comment.