Skip to content

Don't ignore imports with a '# type: ignore' comment #1737

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

Closed
wants to merge 1 commit into from

Conversation

rwbarton
Copy link
Contributor

Instead just try to process them--if that fails, the resulting error
will be ignored anyways.

As far as I can tell, this doesn't actually change any behavior; it's
just a code simplification. It also matches the non-existence of
similar logic in the new fast parser.

Instead just try to process them--if that fails, the resulting error
will be ignored anyways.

As far as I can tell, this doesn't actually change any behavior; it's
just a code simplification. It also matches the non-existence of
similar logic in the new fast parser.
@rwbarton
Copy link
Contributor Author

This is needed for #1695 to not give extraneous warnings about unused # type: ignore comments on imports. (Though arguably it might make sense to never warn about # type: ignore comments on imports, as those are most likely there to cater to a package that may or may not be installed?)

@gvanrossum
Copy link
Member

I don't think I like this (based on just the description). There could be something in the offending module that causes a mypy crash, or it could have errors that we don't want to deal with right now (esp. in a context where we insist on all mypy runs to be error-free).

@rwbarton
Copy link
Contributor Author

Ah, good point. Indeed a # type: ignore comment on an import doesn't just silence errors on that line, but prevents mypy from trying to import the module entirely. (Easy to test: import a module containing a parse error, and then add # type: ignore.) That wasn't so obvious to me, but I guess it's intentional.

In that case, the fast parser should do the same thing; I'll file a ticket for that.

As for #1695, I'll just make it never warn about # type: ignore comments on imports.

@rwbarton rwbarton closed this Jun 22, 2016
rwbarton added a commit to rwbarton/mypy that referenced this pull request Jun 22, 2016
These should cause mypy to skip processing the imported module
entirely, which I tried to break in python#1737.
rwbarton added a commit that referenced this pull request Jun 22, 2016
…1740)

These should cause mypy to skip processing the imported module
entirely, which I tried to break in #1737.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants