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

ethanhs
Copy link
Collaborator

@ethanhs ethanhs 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

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

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

Fixes python#5967
@ethanhs ethanhs requested a review from JukkaL March 26, 2019 06:42
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

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

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 Show resolved Hide resolved
Copy link
Member

@gvanrossum gvanrossum left a comment

Choose a reason for hiding this comment

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

Thanks!

@ethanhs ethanhs merged commit d1e597d into python:master Mar 27, 2019
@ethanhs ethanhs deleted the ignoretypecomment branch March 27, 2019 04:06
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.

None yet

2 participants