Skip to content

Commit c1c8844

Browse files
committed
Skip PyHamcrest typing in mypy
PyHamcrest ships py.typed but the annotations mislead mypy (e.g. all_of/only_contains with Union[Matcher[T], T]). Treat the library as Any by skipping imports until upstream fixes land (see hamcrest/PyHamcrest#267).
1 parent 1718a37 commit c1c8844

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

mypy.ini

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,12 @@ ignore_missing_imports = True
4646
[mypy-compact_json.*]
4747
ignore_missing_imports = True
4848

49+
# PyHamcrest has py.typed but its type annotations are broken - functions like
50+
# all_of() and only_contains() use Union[Matcher[T], T] which mypy can't infer,
51+
# defaulting to Matcher[Never]. Skip analysis to treat as Any.
52+
# TODO: Remove once https://github.com/hamcrest/PyHamcrest/pull/267 is released
4953
[mypy-hamcrest.*]
50-
ignore_missing_imports = True
54+
follow_imports = skip
5155

5256
# reaktiv has type hints but no py.typed marker file
5357
[mypy-reaktiv.*]

0 commit comments

Comments
 (0)