Skip to content

Commit

Permalink
[late] add more typing to the implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
apalala committed Nov 13, 2023
1 parent f784f02 commit c196b38
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions late/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def resolve_default(value):
return {**kwargs, **lateargs}


def latebinding(target):
def latebinding(target: Callable | type) -> Callable | type:
if type(target) is type:
return _latebindclass(target)

Expand All @@ -58,13 +58,13 @@ def wrapper(*args, **kwargs):
return wrapper


def _latebindclass(cls):
old_init = cls.__init__
def _latebindclass(cls: type) -> type:
old_init = cls.__init__ # type: ignore[misc]

@functools.wraps(old_init)
def new_init(self, *args, **kwargs):
kwargs = _lateargs(old_init, **kwargs)
old_init(self, *args, **kwargs)

cls.__init__ = new_init
cls.__init__ = new_init # type: ignore[misc]
return cls

0 comments on commit c196b38

Please sign in to comment.