Skip to content

Commit c356382

Browse files
authored
Merge pull request hamcrest#253 from kalfa/fix_typing
Fix typing for commonly used callables
2 parents 432c410 + 95604e7 commit c356382

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

src/hamcrest/core/core/isinstanceof.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Type
1+
from typing import Type, Any
22

33
from hamcrest.core.base_matcher import BaseMatcher
44
from hamcrest.core.description import Description
@@ -23,7 +23,7 @@ def describe_to(self, description: Description) -> None:
2323
description.append_text("an instance of ").append_text(self.expected_type.__name__)
2424

2525

26-
def instance_of(atype: Type) -> Matcher[object]:
26+
def instance_of(atype: Type[Any]) -> Matcher[object]:
2727
"""Matches if object is an instance of, or inherits from, a given type.
2828
2929
:param atype: The type to compare against as the expected type.

src/hamcrest/core/core/raises.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,9 @@ def describe_match(self, item, match_description: Description) -> None:
8888
)
8989

9090

91-
def raises(exception: Type[Exception], pattern=None, matching=None) -> Matcher[Callable[..., Any]]:
91+
def raises(
92+
exception: Type[Exception], pattern: Optional[str] = None, matching: Optional[Matcher] = None
93+
) -> Matcher[Callable[..., Any]]:
9294
"""Matches if the called function raised the expected exception.
9395
9496
:param exception: The class of the expected exception
@@ -121,7 +123,7 @@ def __init__(self, func: Callable[..., Any]):
121123
def __call__(self):
122124
self.func(*self.args, **self.kwargs)
123125

124-
def with_args(self, *args, **kwargs):
126+
def with_args(self, *args: Any, **kwargs: Any):
125127
self.args = args
126128
self.kwargs = kwargs
127129
return self

0 commit comments

Comments
 (0)