diff --git a/src/hamcrest/core/core/isinstanceof.py b/src/hamcrest/core/core/isinstanceof.py index a34aaa6..b234ca6 100644 --- a/src/hamcrest/core/core/isinstanceof.py +++ b/src/hamcrest/core/core/isinstanceof.py @@ -1,4 +1,4 @@ -from typing import Type +from typing import Type, Any from hamcrest.core.base_matcher import BaseMatcher from hamcrest.core.description import Description @@ -23,7 +23,7 @@ def describe_to(self, description: Description) -> None: description.append_text("an instance of ").append_text(self.expected_type.__name__) -def instance_of(atype: Type) -> Matcher[object]: +def instance_of(atype: Type[Any]) -> Matcher[object]: """Matches if object is an instance of, or inherits from, a given type. :param atype: The type to compare against as the expected type. diff --git a/src/hamcrest/core/core/raises.py b/src/hamcrest/core/core/raises.py index 0fcd6fe..c62bc0c 100644 --- a/src/hamcrest/core/core/raises.py +++ b/src/hamcrest/core/core/raises.py @@ -88,7 +88,9 @@ def describe_match(self, item, match_description: Description) -> None: ) -def raises(exception: Type[Exception], pattern=None, matching=None) -> Matcher[Callable[..., Any]]: +def raises( + exception: Type[Exception], pattern: Optional[str] = None, matching: Optional[Matcher] = None +) -> Matcher[Callable[..., Any]]: """Matches if the called function raised the expected exception. :param exception: The class of the expected exception @@ -121,7 +123,7 @@ def __init__(self, func: Callable[..., Any]): def __call__(self): self.func(*self.args, **self.kwargs) - def with_args(self, *args, **kwargs): + def with_args(self, *args: Any, **kwargs: Any): self.args = args self.kwargs = kwargs return self