Skip to content
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

stubtest does not respect the allowlist when re-exporting #815

Open
jorenham opened this issue Nov 21, 2024 · 1 comment
Open

stubtest does not respect the allowlist when re-exporting #815

jorenham opened this issue Nov 21, 2024 · 1 comment
Labels

Comments

@jorenham
Copy link
Collaborator

jorenham commented Nov 21, 2024

Describe the problem

While stubtesting scipy-stubs while working on a new feature, I got served with the following errors:

$ stubtest --mypy-config-file=pyproject.toml --allowlist=.mypyignore --ignore-unused-allowlist scipy --concise
scipy.special.gammainc variable differs from runtime type numpy.ufunc
scipy.special.gammaincc variable differs from runtime type numpy.ufunc
scipy.special.gammainccinv variable differs from runtime type numpy.ufunc
scipy.special.gammaincinv variable differs from runtime type numpy.ufunc
scipy.special._support_alternative_backends.gammainc variable differs from runtime type numpy.ufunc
scipy.special._support_alternative_backends.gammaincc variable differs from runtime type numpy.ufunc
scipy.special._ufuncs.gammainc variable differs from runtime type numpy.ufunc
scipy.special._ufuncs.gammaincc variable differs from runtime type numpy.ufunc
scipy.special._ufuncs.gammainccinv variable differs from runtime type numpy.ufunc
scipy.special._ufuncs.gammaincinv variable differs from runtime type numpy.ufunc
scipy.stats._qmvnt.gammaincinv variable differs from runtime type numpy.ufunc

The source of these "issues" originate only from .special._ufuncs.
But because these are re-exported in several places, stubtest also reports them there.

The above example is the result of the changes in 4 lines of code, but there are 317 in total 😅

I tried suppressing these errors through the following allowlist entry:

scipy\.special\._ufuncs\..*

This indeed reduces the amount of reported errors, but stubtest still complains about the re-exports, so that's why I consider this a bug.

I am now left with two options:

  • Put the entire scipy.special package in the allowlist. But this would hide all other errors, including the ones that shouldn't be ignored.
  • Manually add the individual allowlist entries for these re-exports. This will amount to at least 317 entries, but it's probably closer to ~500 I'm guessing. For reference, the current allowlist counts 31 lines, which includes comments and blank newlines.

#stublife

Gist to reproduce

No response

Severity

annoying but workaround is available

Your Environment

basedmypy 2.7.0 (compiled: yes)
Based on mypy 1.13.0
@jorenham jorenham added the bug Something isn't working label Nov 21, 2024
@jorenham
Copy link
Collaborator Author

See jorenham/scipy-stubs#189 for the actual code, and my current attempt at a workaround

jorenham added a commit to jorenham/scipy-stubs that referenced this issue Nov 23, 2024
@jorenham jorenham changed the title stubgen does not respect the allowlist when re-exporting stubtest does not respect the allowlist when re-exporting Nov 25, 2024
@jorenham jorenham added stubtest and removed stubgen labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants