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

Internal error when using fmt directives around a decorator #976

Closed
sibsibsib opened this issue Aug 12, 2019 · 1 comment
Closed

Internal error when using fmt directives around a decorator #976

sibsibsib opened this issue Aug 12, 2019 · 1 comment

Comments

@sibsibsib
Copy link

Operating system: macos
Python version: 3.7
Black version: 19.3b0
Does also happen on master: yes [playground link]

Black outputs the following:
INTERNAL ERROR: Black produced invalid code: expected an indented block


to reproduce:

class A:
    # fmt: off
    @decorator(
        param=1,
        foo=2,
    )
    # fmt: on
    def __init__(self):
        pass
        

# this line will be incorrectly indented:
class B:
    # fmt: off
    @decorator(
        param=1,
        foo=2,
    )
    # fmt: on
    def __init__(self):
        pass
                

Additionally, if the second class has no formatting directives the entire class will be indented under the first one.

I'm working around this by moving the directives inside the decorator parens, eg:

@decorator(
    # fmt: off
    param=1,
    foo=2,
    # fmt: on
)
@zsol
Copy link
Collaborator

zsol commented Aug 16, 2019

This is a duplicate of #560.

@zsol zsol closed this as completed Aug 16, 2019
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

No branches or pull requests

2 participants