Skip to content

Commit c09716b

Browse files
committed
fix: support Python 3.14 deferred annotations in modelclass decorator
1 parent ea4ce11 commit c09716b

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

polygon/modelclass.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@
22
import typing
33
from dataclasses import dataclass
44

5-
65
_T = typing.TypeVar("_T")
76

87

98
def modelclass(cls: typing.Type[_T]) -> typing.Type[_T]:
109
cls = dataclass(cls)
10+
type_hints = typing.get_type_hints(cls)
1111
attributes = [
1212
a
13-
for a in cls.__dict__["__annotations__"].keys()
14-
if not a.startswith("__") and not inspect.isroutine(a)
13+
for a in type_hints.keys()
14+
if not a.startswith("__") and not inspect.isroutine(getattr(cls, a, None))
1515
]
1616

1717
def init(self, *args, **kwargs):

0 commit comments

Comments
 (0)