diff --git a/assertpy2/assertpy.py b/assertpy2/assertpy.py index 5f4a667..5945d0a 100644 --- a/assertpy2/assertpy.py +++ b/assertpy2/assertpy.py @@ -722,7 +722,7 @@ class NegatedBuilder: def __init__(self, builder: AssertionBuilder) -> None: self._builder = builder - def __getattr__(self, name: str) -> object: + def __getattr__(self, name: str) -> Callable[..., AssertionBuilder]: if name in _NON_NEGATABLE: raise TypeError(_NON_NEGATABLE[name]) attr = getattr(self._builder, name) diff --git a/tests/test_typing.py b/tests/test_typing.py index 2a33b22..d8980e4 100644 --- a/tests/test_typing.py +++ b/tests/test_typing.py @@ -53,6 +53,7 @@ assert_type(assert_that(bytearray(b"raw")), _BytesAssertion[bytearray]) assert_type(assert_that(len), _CallableAssertion) assert_type(assert_that(object()), AssertionBuilder[object]) + assert_type(assert_that(42).not_.is_equal_to(43), AssertionBuilder[Any]) # The iterable-cluster methods stay on their protocol (return Self), so chaining keeps the type. assert_type(assert_that([1, 2]).satisfies_exactly(lambda x: x > 0, lambda x: x > 1), _IterableAssertion[int])