Skip to content

Allow type ignores after type comments - #6591

Merged
emmatyping merged 4 commits into
python:masterfrom
emmatyping:ignoretypecomment
Mar 27, 2019
Merged

emmatyping merged 4 commits into
python:masterfrom
emmatyping:ignoretypecomment

Conversation

@emmatyping

Copy link
Copy Markdown
Member

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
@emmatyping
emmatyping requested a review from JukkaL March 26, 2019 06:42

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

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.

Comment thread mypy/fastparse.py Resolved
Comment thread mypy/fastparse.py Resolved
Comment thread mypy/fastparse.py Resolved
Comment thread mypy/fastparse.py Resolved
Comment thread mypy/fastparse2.py Resolved

@gvanrossum gvanrossum left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@emmatyping
emmatyping merged commit d1e597d into python:master Mar 27, 2019
@emmatyping
emmatyping 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.

2 participants