-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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: Spurious warning related to symbols in '__all__' #9935
Comments
This example is confusing, since the "stub" stubtest is looking at is actually just the source file. This is a weird way of using stubtest — what are you trying to accomplish? Moreover, the complaint is kind of true.
Note if you were to add Finally, the flag |
As I mentioned before, adding Let's try again, using *.pyi stub files alongside the *.py files: $ mkdir pkg
$ touch pkg/__init__.py
$ touch pkg/__init__.pyi
$ touch pkg/mod.py
$ touch pkg/mod.pyi
$ PYTHONPATH=$PWD stubtest pkg $ echo "__all__=['mod']" > pkg/__init__.py
$ PYTHONPATH=$PWD stubtest pkg
error: pkg.mod is not present in stub
Stub:
MISSING
Runtime:
MISSING IMHO, the complaint is not true, this is a perfectly valid Python package. The fact that $ PYTHONPATH=$PWD python -c "from pkg import *; print(mod)"
<module 'pkg.mod' from '/tmp/pkg/mod.py'> so there is no real requirement for I'm not sure of this behavior of I'm trying to use |
This kind of helps resolve python#9935
This kind of helps resolve python#9935
Okay, gotcha. I think mypy in general doesn't handle this use of
Anyway, for now I opened #9943 which should fix the runtime half of stubtest. That is, after that PR you would be able to get things working by adding cc @srittau since you were resurrecting the stub PEP and you might have opinions about how |
We decided that it's probably best if |
* stubtest: import submodules mentioned in __all__ This kind of helps resolves #9935 Co-authored-by: hauntsaninja <>
Bug Report
I'm getting an error from
stubtest
checking a package that lists a submodule in__all__
.To Reproduce
stubtest
seems to be happy with it$ PYTHONPATH=$PWD stubtest pkg
mod
to__all__
in__init.py
and runstubtest
againNote, adding respective
*.pyi
files do not fix the problem.The text was updated successfully, but these errors were encountered: