-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Importing from non-py.typed module -> "Module has no attribute" with --strict; mypy still suggests the names it doesn't accept #13908
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
Labels
bug
mypy got something wrong
Comments
This is because That said, the error message should clearly be better. #9084 / #9237 improved the error message, but looks like due to various issues with the implementation it doesn't actually trigger on your example. Easy enough to fix though |
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Oct 18, 2022
Also only suggest public API for attribute access suggestions Fixes python#13908 Accomplishes a similar thing to python#9084 (the logic from there could be improved too, will send a PR for that next)
hauntsaninja
added a commit
that referenced
this issue
Oct 19, 2022
hauntsaninja
added a commit
to hauntsaninja/mypy
that referenced
this issue
Oct 19, 2022
Related to python#13917 and python#13908. This handles situations involving per-module re-exports correctly / is consistent with the error you'd get with attribute access.
hauntsaninja
added a commit
that referenced
this issue
Oct 20, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To me, this issue has a vague resemblance to #10360. I do not know if it is really related.
With
--strict
, referring to variables imported from a non-py.typed module in another module causes mypy to output two error messages of the formModule has no attribute A; maybe B?
andModule has no attribute B; maybe A?
, for the same module. This obviously does not make a whole lot of sense.I do not know if this applies generally to non-py.typed packages or if there's something special about the diffusers package I used.
How to reproduce
(see the Environment section for the precise packages installed by this)
Actual Behavior
Without
--strict
, the "Skipping analyzing" error is the only one produced. With--ignore-missing-imports
or# type: ignore[import]
for theimport
in bug.py, only the "Module has no attribute" errors are produced.Expected Behavior
Mypy should
bug
module;So I would expect the "Skipping analyzing" to be the only error message mypy outputs.
Your Environment
mypy 0.982 (compiled: yes)
--config-file= --strict
mypy.ini
(and other config files): None (--config-file=
)The text was updated successfully, but these errors were encountered: