Skip to content

Commit

Permalink
feat: add type annotations to modelclass (#425)
Browse files Browse the repository at this point in the history
fixes: #424
  • Loading branch information
shooit authored Aug 4, 2023
1 parent 73b21f8 commit 1f9dac6
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions polygon/modelclass.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
import inspect
import typing
from dataclasses import dataclass


def modelclass(cls):
_T = typing.TypeVar("_T")


def modelclass(cls: typing.Type[_T]) -> typing.Type[_T]:
cls = dataclass(cls)
attributes = [
a
Expand All @@ -18,6 +22,6 @@ def init(self, *args, **kwargs):
if k in attributes:
self.__dict__[k] = v

cls.__init__ = init
cls.__init__ = init # type: ignore[assignment]

return cls

0 comments on commit 1f9dac6

Please sign in to comment.