Skip to content

Commit e143a03

Browse files
committed
🔨 python-version-dependent stubtest allowlists
1 parent 1037540 commit e143a03

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

‎tool/.mypyignore-ge312.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# python >= 3.12
2+
3+
numpy\.distutils

‎tool/.mypyignore-lt312.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# python < 3.12
2+
3+
# TODO(jorenham): https://github.com/numpy/numtype/issues/41
4+
numpy\.distutils\..+
5+
6+
# blame typeshed
7+
numpy\.compat(\.py3k)?\.bytes\.__buffer__

‎tool/.mypyignore-todo renamed to ‎tool/.mypyignore-todo.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ numpy(\..+)?\.floating.as_integer_ratio
88
numpy(\..+)?\.complexfloating.__hash__
99
numpy(\..+)?\.complexfloating.__complex__
1010

11-
numpy.distutils
1211

1312
numpy.f2py.__main__
1413
numpy.f2py.__version__

‎tool/.mypyignore renamed to ‎tool/.mypyignore.txt

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,9 @@ numpy\._core\.cversions
2727
# mypy plugin
2828
numpy\.typing\.mypy_plugin
2929

30-
# workaround mypy's lack of Python 3.13 support for `NamedTuple` types (mypy <= 1.15.0)
31-
numpy(\.\w+)+\.__replace__
32-
3330
# workaround for https://github.com/python/mypy/issues/15302#issuecomment-2701979355
3431
numpy\.testing(\._private\.utils)?\.check_support_sve
3532

36-
# workaround for stubtest ignoring `if sys.version_info` blocks in `_typeshed` when
37-
# `python_version`
38-
numpy\.compat(\.py3k)?\.(Path|os_PathLike|bytes)\.[_a-zA-Z]+
39-
numpy\.testing\.TestCase\.[_a-zA-Z]+
33+
# blame typeshed
34+
numpy\.compat(\.py3k)?\.os_PathLike\.__class_getitem__
35+
numpy\.testing\.TestCase\.__init_subclass__

‎tool/stubtest.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,11 @@
2929
ROOT_DIR = TOOL_DIR.parent
3030
ROOT_SITE_DIR = next((ROOT_DIR / ".venv" / "lib").glob("*/site-packages"))
3131

32-
ALLOWLISTS = ".mypyignore", ".mypyignore-todo"
32+
ALLOWLISTS = [
33+
".mypyignore.txt",
34+
".mypyignore-todo.txt",
35+
".mypyignore-gt312.txt" if sys.version_info >= (3, 12) else ".mypyignore-lt312.txt",
36+
]
3337

3438

3539
def __commit_pyi_genocide_for_mypy() -> None:
@@ -84,7 +88,6 @@ def _rewrite_mypy_output(line: bytes, /) -> bytes:
8488
str
8589
"""
8690
line = line.replace(b"builtins.", b"")
87-
line = line.replace(b"numpy.", b"np.")
8891

8992
if len(line.strip()) <= len(str(SITE_DIR)):
9093
return line

0 commit comments

Comments
 (0)