File tree Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Expand file tree Collapse file tree 2 files changed +10
-13
lines changed Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ def __check_simd() -> None:
71
71
72
72
def __commit_pyi_genocide_for_mypy () -> None :
73
73
"""
74
- Remove the ``py.typed`` and all ``*.pyi`` files from the installed numpy package.
74
+ Remove all ``__init__.pyi`` files from the installed numpy package.
75
+
76
+ This works around https://github.com/python/mypy/issues/18997 on `mypy<1.16.0`.
75
77
76
78
Raises
77
79
------
@@ -82,15 +84,9 @@ def __commit_pyi_genocide_for_mypy() -> None:
82
84
if not package .is_dir ():
83
85
raise NotADirectoryError (f"{ package } does not exist" )
84
86
85
- py_typed = package / "py.typed"
86
- if py_typed .is_file ():
87
- py_typed .unlink ()
88
- if VERBOSE :
89
- print (f"deleted { py_typed } (1)" )
90
-
91
- graveyard_size = sum (not pyi .unlink () for pyi in package .rglob ("*.pyi" )) # type: ignore[func-returns-value]
87
+ graveyard_size = sum (not pyi .unlink () for pyi in package .rglob ("__init__.pyi" )) # type: ignore[func-returns-value]
92
88
if VERBOSE and graveyard_size :
93
- print (f"deleted { package } /**/* .pyi ( { graveyard_size } ) \n " )
89
+ print (f"deleted { graveyard_size } __init__ .pyi from { package } \n " )
94
90
95
91
96
92
def _allowlists () -> list [str ]:
Original file line number Diff line number Diff line change 1
1
"""
2
- Delete all `.pyi` files in the `numpy` site-packages directory.
2
+ Delete all `__init__.pyi` files in the `numpy` site-packages directory.
3
+
4
+ This is a workaround for https://github.com/python/mypy/issues/18997 on `mypy<1.16.0`
3
5
4
6
Run with `uv run tool/unstub.py`.
5
7
"""
10
12
package = Path (sysconfig .get_paths ()["purelib" ]) / "numpy"
11
13
assert package .is_dir (), package
12
14
13
- (package / "py.typed" ).unlink (missing_ok = True )
14
- bodycount = sum (not pyi .unlink () for pyi in package .rglob ("*.pyi" )) # type: ignore[func-returns-value]
15
- print (f"{ bodycount } files deleted from { package .relative_to (Path .cwd ())} /**/*.pyi" )
15
+ bodycount = sum (not pyi .unlink () for pyi in package .rglob ("__init__.pyi" )) # type: ignore[func-returns-value]
16
+ print (f"{ bodycount } files deleted from { package .relative_to (Path .cwd ())} " )
You can’t perform that action at this time.
0 commit comments