Skip to content

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.

2 participants