Skip to content

Commit 1f9dac6

Browse files
authored
feat: add type annotations to modelclass (#425)
fixes: #424
1 parent 73b21f8 commit 1f9dac6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

polygon/modelclass.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
import inspect
2+
import typing
23
from dataclasses import dataclass
34

45

5-
def modelclass(cls):
6+
_T = typing.TypeVar("_T")
7+
8+
9+
def modelclass(cls: typing.Type[_T]) -> typing.Type[_T]:
610
cls = dataclass(cls)
711
attributes = [
812
a
@@ -18,6 +22,6 @@ def init(self, *args, **kwargs):
1822
if k in attributes:
1923
self.__dict__[k] = v
2024

21-
cls.__init__ = init
25+
cls.__init__ = init # type: ignore[assignment]
2226

2327
return cls

0 commit comments

Comments
 (0)