Thanks to visit codestin.com
Credit goes to github.com

Skip to content

TST: Remove most */tests/__init__.py #29246

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jorenham
Copy link
Member

@jorenham jorenham commented Jun 20, 2025

x-ref: microsoft/pyright#10614 (reply in thread)


But unfortunately this does help increase the "type completeness score". Running pyright --ignoreexternal --verifytypes numpy (after pip install .) shows the following:

before:

Symbols exported by "numpy": 9899
  With known type: 4446
  With ambiguous type: 485
  With unknown type: 4968
    (Ignoring unknown types imported from other packages)

Other symbols referenced but not exported by "numpy": 1658
  With known type: 1592
  With ambiguous type: 1
  With unknown type: 65

Symbols without documentation:
  Functions without docstring: 4625
  Functions without default param: 353
  Classes without docstring: 966

Type completeness score: 44.9%

Completed in 4.313sec

after:

Symbols exported by "numpy": 9841
  With known type: 4412
  With ambiguous type: 480
  With unknown type: 4949
    (Ignoring unknown types imported from other packages)

Other symbols referenced but not exported by "numpy": 1642
  With known type: 1568
  With ambiguous type: 2
  With unknown type: 72

Symbols without documentation:
  Functions without docstring: 4615
  Functions without default param: 353
  Classes without docstring: 962

Type completeness score: 44.8%

Completed in 4.267sec

So I suppose that the main advantage is that tests is no longer directly importable


Note that this does not remove _pyinstaller/tests/__init__.py and distutils/tests/__init__.py.

@rgommers
Copy link
Member

I refreshed my memory on why the __init__.py files were added in the first place:

So that was for run_module_suite, which was removed for the 1.25.0 release. So it should be fine removing __init__.py files now, if CI is happy.

@mhvk
Copy link
Contributor

mhvk commented Jun 21, 2025

I guess this is for testing purposes only, but in case, are you sure removing the __init__.py is an advantage? In astropy at least, I've at times had sessions where it was helpful to just import a test class/function and run them (with parametrized tests, it allows trying different values). Obviously, not a huge deal, but maybe a reason to just leave things as they are.

p.s. I'm also surprised at the renaming - why rename test_regression.py to include the module name? The advantage of namespaces is that one doesn't have to!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants