Skip to content

Commit

Permalink
Fix is_() type annotations.
Browse files Browse the repository at this point in the history
  • Loading branch information
brunns authored and offbyone committed Aug 11, 2021
1 parent 8593194 commit b91c916
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions src/hamcrest/core/core/is_.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import Optional, Type, TypeVar, Union, overload
from typing import Optional, Type, TypeVar, overload, Any

from hamcrest.core.base_matcher import BaseMatcher
from hamcrest.core.description import Description
Expand Down Expand Up @@ -46,12 +46,17 @@ def _wrap_value_or_type(x):


@overload
def is_(x: Type) -> Matcher[object]:
def is_(x: Type) -> Matcher[Any]:
...


@overload
def is_(x: Union[Matcher[T], T]) -> Matcher[T]:
def is_(x: Matcher[T]) -> Matcher[T]:
...


@overload
def is_(x: T) -> Matcher[T]:
...


Expand Down
2 changes: 1 addition & 1 deletion tests/type-hinting/test_test_types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@
main: |
from hamcrest.library.text.isequal_ignoring_case import equal_to_ignoring_case
reveal_type(equal_to_ignoring_case("")) # N: Revealed type is 'hamcrest.core.matcher.Matcher[builtins.str]'
reveal_type(equal_to_ignoring_case("")) # N: Revealed type is "hamcrest.core.matcher.Matcher[builtins.str]"

0 comments on commit b91c916

Please sign in to comment.