File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,7 +71,9 @@ def __check_simd() -> None:
7171
7272def __commit_pyi_genocide_for_mypy () -> None :
7373 """
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`.
7577
7678 Raises
7779 ------
@@ -82,15 +84,9 @@ def __commit_pyi_genocide_for_mypy() -> None:
8284 if not package .is_dir ():
8385 raise NotADirectoryError (f"{ package } does not exist" )
8486
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]
9288 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 " )
9490
9591
9692def _allowlists () -> list [str ]:
Original file line number Diff line number Diff line change 11"""
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`
35
46Run with `uv run tool/unstub.py`.
57"""
1012package = Path (sysconfig .get_paths ()["purelib" ]) / "numpy"
1113assert package .is_dir (), package
1214
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