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

Crash possibly due to mismatched indents after # fmt: off? #3702

Closed
Zac-HD opened this issue May 24, 2023 · 1 comment
Closed

Crash possibly due to mismatched indents after # fmt: off? #3702

Zac-HD opened this issue May 24, 2023 · 1 comment
Labels
T: bug Something isn't working

Comments

@Zac-HD
Copy link
Contributor

Zac-HD commented May 24, 2023

With current latest black, 23.3.0 (compiled: yes):

import black

code = """
if True:
  # fmt: off
  pass
  # fmt: on
  pass
"""
black.format_str(code, mode=black.FileMode())
Traceback (most recent call last):
  File "repro.py", line 10, in <module>
    black.format_str(code, mode=black.FileMode())
  File "src/black/__init__.py", line 1084, in format_str
  File "src/black/__init__.py", line 1089, in _format_str_once
  File "src/black/parsing.py", line 127, in lib2to3_parse
black.parsing.InvalidInput: Cannot parse: 5:0:     pass

This passes if you use four-space indentation. Possibly related to #3458?

@JelleZijlstra
Copy link
Collaborator

Duplicate of #3505

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants