-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Too strict behavior with --ignore-missing-imports #5226
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
Comments
I believe this has been discussed before but I don't recall the outcome.
:-( Isn't this the reason we don't like partial packages in typeshed?
…On Sat, Jun 16, 2018, 18:11 Ivan Levkivskyi ***@***.***> wrote:
I think the --ignore-missing-imports currently behaves a bit
inconsistently. If I have an existing directory with only an empty
__init__.py, then running mypy with --ignore-missing-imports gives this:
import whatever.worksimport existing.nonexisting
x = whatever.works.f() # No errors, as expected
y = existing.nonexisting.g() # Module has no attribute "nonexisting"
At the same time both these work:
from whatever import works # no errorsfrom existing import nonexisting # no errors
I think the first example should work as well, since all non-existing
modules should be replaced with a dummy Any (and apparently it looks easy
to fix, unless this is intentional behavior for some reasons).
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#5226>, or mute the thread
<https://github.com/notifications/unsubscribe-auth/ACwrMv0cInK58Vjt-_y95-T-of1A8wJqks5t9azPgaJpZM4UqqqS>
.
|
Maybe. But what is the value of that error "Module has no attribute ..."? |
Correction: |
For me the deciding difference is whether it could reference something other than a module. So I don't necessarily believe that "fixing" this will make things better -- it will just trade false positives for false negatives. |
So do you prefer false positives? I prefer false negatives. Also as Jukka mentioned in the PR some users may be surprised that refactoring |
In the end I agree that we need to solve this. I just wanted to explain
that the original behavior was not that irrational but in fact was
internally consistent. (The new solution will be too of course.)
|
OK, I updated the title. |
Fixes #5226 With this change, the following ``` import existing_package.non_existing_mod x = existing_package.non_existing_mod.some_func() ``` will be allowed under `--ignore-missing-imports`
I think the
--ignore-missing-imports
currently behaves a bit inconsistently. If I have anexisting
directory with only an empty__init__.py
, then running mypy with--ignore-missing-imports
gives this:At the same time both these work (in the same program, otherwise the second fails):
I think the first example should work as well, since all non-existing modules should be replaced with a dummy
Any
(and apparently it looks easy to fix, unless this is intentional behavior for some reasons).EDIT: see #5226 (comment)
The text was updated successfully, but these errors were encountered: