Skip to content

Make mypy still check imports with # type: ignore comments if the import exists #1912

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

Merged
merged 6 commits into from
Jul 19, 2016

Conversation

Michael0x2a
Copy link
Collaborator

@Michael0x2a Michael0x2a commented Jul 19, 2016

This pull request fixes #1911. It also incidentally fixes #1904, which means that we can close #1906 since it's superseded by this pull request. However, this pull request does NOT fix issue #1910, which appears to be an unrelated bug.

if self.errors.num_messages() != num_errs:
self.log("Bailing due to parse errors")
self.errors.raise_error()

# We don't want to warn about 'type: ignore' comments on imports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be "... about unused '# type: ignore' comments ...". Also please clarify that this is because an import might be valid on some platform and invalid on another.

(Come to think of it, that could in theory also be a concern with --warn-unused-ignores in other places, but much less probable.)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the right decision. You're not intended to always run with --warn-unused-ignores in CI, for example, because this can be a problem in other places (like when you're transitioning between mypy releases). --warn-unused-ignores is intended to be run periodically to clean up unnecessary # type: ignore comments and is intended to require human judgement in the loop. If something is even just potentially unused, we should warn about it here.

Put another way: if we don't warn about type ignore comments on imports, they'll never be removed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe, but this is how it already works (Michael just updated the comment and moved the line). If you feel strongly about this please file a separate bug.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It only worked that way before because a # type: ignore on an import always had an effect. Filed #1913.

@gvanrossum gvanrossum merged commit a0eadce into python:master Jul 19, 2016
@Michael0x2a Michael0x2a deleted the make-type-ignore-less-severe branch July 21, 2016 20:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants