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

Comments within fmt: off/on are formatted #2110

Closed
kenodegard opened this issue Apr 15, 2021 · 2 comments
Closed

Comments within fmt: off/on are formatted #2110

kenodegard opened this issue Apr 15, 2021 · 2 comments
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@kenodegard
Copy link

Describe the bug Comments occurring directly before # fmt: on (but still within the # fmt: off block) are formatted.

To Reproduce Steps to reproduce the behavior:

  1. Take this:
# fmt: off
#poorly formatted comment
a=1
#another poorly formatted comment
#multiple lines are impacted
# fmt: on
#comment to correct
b=2
  1. Run Black on it.
  2. Result versus Expected:
Result Expected
# fmt: off
#poorly formatted comment
a=1
# another poorly formatted comment
# multiple lines are impacted
# fmt: on
# comment to correct
b = 2
# fmt: off
#poorly formatted comment
a=1
#another poorly formatted comment
#multiple lines are impacted
# fmt: on
# comment to correct
b = 2

Expected behavior I do not expect anything within the # fmt: off/# fmt: on block to be touched.

Environment (please complete the following information):

  • Version: 20.8b1
  • OS and Python version: Mac 11.2.3/Python 3.9.0 and Windows 10/Python 3.9.2

Does this bug also happen on master? Yes - tested with https://black.now.sh/?version=master

@kenodegard kenodegard added the T: bug Something isn't working label Apr 15, 2021
@ichard26
Copy link
Collaborator

ichard26 commented Apr 17, 2021

Thanks for the bug report, (un)fortanately we know of this issue already (tracked in GH-1245) so I'm going to close this issue as a duplicate of that issue.

p.s. awesome bug report, super readable and easy to parse!
p.s.s. I tried to fix this bug and I failed even after a lot of hours

edit: I fixed the bug, but the patch is so messy that I'm not going to even consider submitting a PR yet

@ichard26 ichard26 added the R: duplicate This issue or pull request already exists label Apr 17, 2021
@kenodegard
Copy link
Author

Oops! I tried searching for related bugs but clearly failed! Thanks for taking a look/closing!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
R: duplicate This issue or pull request already exists T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants