When running mypy on code using matchers, it complains about incompatible arguments, because responses' type annotations are too restrictive: Dict (which is invariant) rather than Mapping.
it complains about the arguments being incompatible.
error: Argument 1 to "header_matcher" has incompatible type "dict[str, str]"; expected "dict[str, str | Pattern[str]]" [arg-type]
note: "Dict" is invariant -- see https://mypy.readthedocs.io/en/stable/common_issues.html#variance
note: Consider using "Mapping" instead, which is covariant in the value type
Describe the bug
When running mypy on code using matchers, it complains about incompatible arguments, because responses' type annotations are too restrictive:
Dict
(which is invariant) rather thanMapping
.it complains about the arguments being incompatible.
Additional context
https://mypy.readthedocs.io/en/stable/common_issues.html#variance
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#standard-duck-types
Version of
responses
0.24.1
Steps to Reproduce
Run mypy over:
Expected Result
mypy succeeds without issues
Actual Result