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 could not format file #2497

Closed
lissom opened this issue Sep 17, 2021 · 1 comment
Closed

Black could not format file #2497

lissom opened this issue Sep 17, 2021 · 1 comment
Labels
C: invalid code Black destroyed a valid Python file F: fmtoff fmt: off implementation R: duplicate This issue or pull request already exists T: bug Something isn't working

Comments

@lissom
Copy link

lissom commented Sep 17, 2021

error: cannot format black_src_error2.py: INTERNAL ERROR: Black produced code that is not equivalent to the source on pass 1. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: black_error2.log

black --line-length 130

black 21.9b0

Linux/Python 3.7.10
black_error2.log

black_src_error2.zip

@lissom lissom added the T: bug Something isn't working label Sep 17, 2021
@ichard26 ichard26 added C: invalid code Black destroyed a valid Python file F: fmtoff fmt: off implementation R: duplicate This issue or pull request already exists labels Sep 19, 2021
@ichard26
Copy link
Collaborator

Hello! This is actually an issue we are already aware of: #569. The gist of it is that Black really misbehaves when an indented fmt: off comment's scope continues even after the indentation is gone. There seem to a minor mix-up in your code that triggers this:

    @staticmethod
    def add_args(parser):
        # fmt: on
        parser.add_argument('--log-group-name', required=True, type=str, help='The cluster config field to pull the AWS log group name from')
        parser.add_argument('--log-stream-name', default=get_instance_id(), type=str, help='The AWS log stream name, defaults to the instance id')
        parser.add_argument('--watch-path', required=True, type=str, help='The directory with files to monitor')
        parser.add_argument('--suffix', default='.log', type=str, help='Only monitor files with this suffix.  Defaults to .log; default python rotation is x.{1,2,3...}')
        parser.add_argument('--log-sent-lines', default=False, action='store_true', help='Log lines sent to aws')
        # fmt: off

Obviously it would be better if Black didn't mess up the indentation in this situation but we haven't gotten around to that yet. I'll be closing this issue as this is a duplicate of #569. Thanks for the report and my apologies Black didn't work right for you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C: invalid code Black destroyed a valid Python file F: fmtoff fmt: off implementation 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