Skip to content

Commit

Permalink
TYP,TST: Add tests for known mypy-related false-positives
Browse files Browse the repository at this point in the history
These all concern known false positives due to known mypy bugs. If one of these tests break, than that would generally be indicative of a upstream bug fix
  • Loading branch information
BvB93 committed Feb 21, 2022
1 parent fc1de7a commit b9833cc
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
11 changes: 11 additions & 0 deletions numpy/typing/tests/data/fail/false_positives.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import numpy as np
import numpy.typing as npt

AR_f8: npt.NDArray[np.float64]

# NOTE: Mypy bug presumably due to the special-casing of heterogeneous tuples;
# xref numpy/numpy#20901
#
# The expected output should be no different than, e.g., when using a
# list instead of a tuple
np.concatenate(([1], AR_f8)) # E: Argument 1 to "concatenate" has incompatible type
10 changes: 10 additions & 0 deletions numpy/typing/tests/data/reveal/false_positives.pyi
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from typing import Any
import numpy.typing as npt

AR_Any: npt.NDArray[Any]

# Mypy bug where overload ambiguity is ignored for `Any`-parametrized types;
# xref numpy/numpy#20099 and python/mypy#11347
#
# The expected output would be something akin to `ndarray[Any, dtype[Any]]`
reveal_type(AR_Any + 2) # E: ndarray[Any, dtype[signedinteger[Any]]]

0 comments on commit b9833cc

Please sign in to comment.