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

Black's behavior with comments is not described in the style guide #1017

Closed
kylrth opened this issue Sep 12, 2019 · 4 comments · Fixed by #2306
Closed

Black's behavior with comments is not described in the style guide #1017

kylrth opened this issue Sep 12, 2019 · 4 comments · Fixed by #2306
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: documentation Improvements to the docs (e.g. new topic, correction, etc)

Comments

@kylrth
Copy link

kylrth commented Sep 12, 2019

I had to go to #208 to finally find out that Black does not reformat comments. I shouldn't have to find a GitHub conversation from 2018 to find out how Black handles comments.

An explanation should be added to the readme.

@edreamleo
Copy link

I heartily second this suggestion.

Am I correct that black puts two spaces before trailing comments?

# Before:
atFile = AtFile # compatibility
# After:
atFile = AtFile  # compatibility

This is a real change. It should, at minimum, be documented somewhere.

@hugovk
Copy link
Contributor

hugovk commented Sep 12, 2019

Am I correct that black puts two spaces before trailing comments?

Yes, it's in PEP 8:

An inline comment is a comment on the same line as a statement. Inline comments should be separated by at least two spaces from the statement. They should start with a # and a single space.

@edreamleo
Copy link

@hugovk Thanks for the clarification.

@ichard26 ichard26 added F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: documentation Improvements to the docs (e.g. new topic, correction, etc) labels May 30, 2021
@ichard26
Copy link
Collaborator

Given how warmly received this has been by the community, I would definitely accept a patch for this!

Thanks for the suggestion!

p.s. info about how some comments get special treatment, may be moved where linters then get mad, etc. (i.e. the edge cases) should definitely be included

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F: comments The syntactic kind. Not in the language grammar, always on our minds. Best bugs. T: documentation Improvements to the docs (e.g. new topic, correction, etc)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants