Skip to content

Commit

Permalink
Merge pull request #253 from kalfa/fix_typing
Browse files Browse the repository at this point in the history
Fix typing for commonly used callables
  • Loading branch information
offbyone authored Sep 26, 2024
2 parents 432c410 + 95604e7 commit c356382
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/hamcrest/core/core/isinstanceof.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand Down
6 changes: 4 additions & 2 deletions src/hamcrest/core/core/raises.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit c356382

Please sign in to comment.