In the example below I have used has_items and has_properties however I am seeing this with contains and friends and has_entries as well.
Minimal reproducable example
Packages
mypy==0.971
PyHamcrest==2.0.3
Example
from dataclasses import dataclass
from hamcrest import assert_that, has_items, has_properties
@dataclass
class Example:
name: str
age: int
items = [Example("dave", 1), Example("wave", 2)]
assert_that(
items,
has_items(
has_properties(name="dave", age=1),
has_properties(name="wave", age=2),
),
)
Expected outcome
mypy does not complain as this is a valid use of has_items and has_properties.
Actual outcome
mypy returns the following error
test.py:13: error: Cannot infer type argument 1 of "assert_that"
test.py:16: error: Argument 1 to "has_items" has incompatible type "Matcher[object]"; expected "Matcher[<nothing>]"
test.py:17: error: Argument 2 to "has_items" has incompatible type "Matcher[object]"; expected "Matcher[<nothing>]"
Found 3 errors in 1 file (checked 1 source file)
In the example below I have used
has_items
andhas_properties
however I am seeing this withcontains
and friends andhas_entries
as well.Minimal reproducable example
Packages
Example
Expected outcome
mypy does not complain as this is a valid use of
has_items
andhas_properties
.Actual outcome
mypy returns the following error