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

Don't allow type comments to be merged behind regular comments #1027

Merged
merged 1 commit into from
Sep 17, 2019

Conversation

msullivan
Copy link
Contributor

@msullivan msullivan commented Sep 17, 2019

Type comments only apply if they are the first comment on the line,
which means that allowing them to be pushed behind a regular comment
when joining lines is a semantic change (and, indeed, one that black
catches and fails on).

(This issue discovered in the wild at Dropbox by a user who accidentally omitted a colon in a type comment and was confused to find black crashing.)

Type comments only apply if they are the first comment on the line,
which means that allowing them to be pushed behind a regular comment
when joining lines is a semantic change (and, indeed, one that black
catches and fails on).
@JelleZijlstra JelleZijlstra merged commit 0c44220 into psf:master Sep 17, 2019
@JelleZijlstra
Copy link
Collaborator

Thanks!

@msullivan msullivan deleted the type-comment-fix branch September 17, 2019 22:12
msullivan added a commit to msullivan/black that referenced this pull request Oct 10, 2019
The code introduced in psf#1027 to detect whether a type comment appeared
after a regular comment in a Line would spuriously misfire when a leaf
was in the comments dict but had an empty list of comments. This can
occur as an artifact of how comments on trailing commas are handled,
it seems.

(This was discovered trying to test black out on mypy.)
JelleZijlstra pushed a commit that referenced this pull request Oct 10, 2019
The code introduced in #1027 to detect whether a type comment appeared
after a regular comment in a Line would spuriously misfire when a leaf
was in the comments dict but had an empty list of comments. This can
occur as an artifact of how comments on trailing commas are handled,
it seems.

(This was discovered trying to test black out on mypy.)
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