Skip to content
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

Allow type ignores after type comments #6591

Merged
merged 4 commits into from Mar 27, 2019

Conversation

Projects
None yet
2 participants
@ethanhs
Copy link
Collaborator

commented Mar 26, 2019

This is a hack in fastparse, but allows for the following to pass typechecking:

x = 1 # type: str # type: ignore

This also handles the edge case where there is a # type: ignore in a comment, which we don't want to pick up. See the tests for more examples.

Fixes #5967

ethanhs added some commits Mar 26, 2019

Allow type ignores after type comments
This is a bit of a hack in fastparse, but allows for the following to pass typechecking:

`x = 1  # type: str  # type: ignore`

Fixes #5967

@ethanhs ethanhs requested a review from JukkaL Mar 26, 2019

@gvanrossum
Copy link
Member

left a comment

Thanks! I've wanted this many times. Here are a few nits.

Show resolved Hide resolved mypy/fastparse.py Outdated
Show resolved Hide resolved mypy/fastparse.py Outdated
Show resolved Hide resolved mypy/fastparse.py Outdated
Show resolved Hide resolved mypy/fastparse.py Outdated
Show resolved Hide resolved mypy/fastparse2.py Outdated

ethanhs added some commits Mar 27, 2019

@gvanrossum
Copy link
Member

left a comment

Thanks!

@ethanhs ethanhs merged commit d1e597d into python:master Mar 27, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@ethanhs ethanhs deleted the ethanhs:ignoretypecomment branch Mar 27, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.