Skip to content

Commit 06a8109

Browse files
committed
fix type checking for lat-bound callables
1 parent ebbab13 commit 06a8109

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Diff for: late/__init__.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
__all__ = ['latebinding', 'late', '__']
88

99

10+
_R = TypeVar('_R')
1011
_T = TypeVar('_T')
1112
_V = TypeVar('_V')
1213

@@ -15,7 +16,7 @@ class _LateBound(NamedTuple):
1516
actual: Any
1617

1718

18-
def late(o: _T | Iterator[_V]) -> _T | _V:
19+
def late(o: _T | Iterator[_V] | Callable[[], _R]) -> _T | _V | _R:
1920
if isinstance(o, int | float | str | bool | bytes | bytearray | frozenset):
2021
return o # type: ignore
2122

Diff for: test/complex_test.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def a() -> int:
2323
return t
2424

2525
@latebinding
26-
def f(x: int = __(a)) -> int: # type: ignore
26+
def f(x: int = __(a)) -> int:
2727
return 2 * x
2828

2929
assert f() == 2

0 commit comments

Comments
 (0)