Skip to content

Commit 1fcdf12

Browse files
authored
Merge pull request #26 from OpenHCSDev/b6-py314-annotations
2.1.1: own annotations through inspect.get_annotations (Python 3.14)
2 parents aa7381f + a44b90b commit 1fcdf12

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

‎src/objectstate/__init__.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@
212212
'ObjectStateEditSession',
213213
]
214214

215-
__version__ = "2.1.0"
215+
__version__ = "2.1.1"
216216
__author__ = 'OpenHCS Team'
217217
__description__ = 'Generic configuration framework for lazy dataclass resolution'
218218

‎src/objectstate/lazy_factory.py‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# Standard library imports
44
import copy
55
import dataclasses
6+
import inspect
67
import logging
78
import re
89
import sys
@@ -91,10 +92,9 @@ def get_inherited_field_names(cls: Type) -> set:
9192
if dataclasses.is_dataclass(base):
9293
parent_fields.update(base.__dataclass_fields__.keys())
9394

94-
# Get cls's OWN annotations (not inherited) - check __dict__ not getattr
95-
own_defined = set()
96-
if '__annotations__' in cls.__dict__:
97-
own_defined = set(cls.__dict__['__annotations__'].keys())
95+
# cls's OWN annotations (not inherited). Python 3.14 (PEP 649) no longer
96+
# stores them in cls.__dict__['__annotations__'].
97+
own_defined = set(inspect.get_annotations(cls, eval_str=False))
9898

9999
return parent_fields - own_defined
100100

@@ -1455,7 +1455,7 @@ def _extract_abbreviations_from_annotations(cls: Type) -> Dict[str, str]:
14551455
continue
14561456

14571457
# Get this class's own annotations (not inherited)
1458-
annotations = klass.__dict__.get('__annotations__', {})
1458+
annotations = inspect.get_annotations(klass, eval_str=False)
14591459

14601460
for field_name, field_type in annotations.items():
14611461
# Check if this is an Annotated type

0 commit comments

Comments
 (0)