-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Closed
Labels
F: fmtofffmt: off implementationfmt: off implementationT: enhancementNew feature or requestNew feature or request
Description
Describe the bug
If you forget to add # fmt: on after a # fmt: off, you get an unhelpful error message.
To Reproduce
- Take this file
repro.py
def f():
# fmt: off
pass
if True:
pass-
Run
black --check repro.py -
See error:
error: cannot format repro.py: INTERNAL ERROR: Black produced code that is not equivalent to the source. Please report a bug on https://github.com/psf/black/issues. This diff might be helpful: /tmp/blk_k081_p1l.log
Oh no! 💥 💔 💥
1 file would fail to reformat.
Expected behavior
I would expect that this either works (and it just ignores the rest of the file), or that you get an error message telling you that you need to add # fmt: on somewhere.
Environment (please complete the following information):
- Version: 20.8b1
- OS and Python version: Ubuntu 20.04, Python 3.8.5
Does this bug also happen on master?
Yes, it happens on https://black.now.sh/?version=master
Additional context
Here's the output of /tmp/blk_k081_p1l.log:
--- src
+++ dst
@@ -14,26 +14,26 @@
None, # NoneType
) # /arguments
body=
Pass(
) # /Pass
+ If(
+ body=
+ Pass(
+ ) # /Pass
+ orelse=
+ test=
+ Constant(
+ value=
+ True, # bool
+ ) # /Constant
+ ) # /If
decorator_list=
name=
'f', # str
returns=
None, # NoneType
type_comment=
None, # NoneType
) # /FunctionDef
- If(
- body=
- Pass(
- ) # /Pass
- orelse=
- test=
- Constant(
- value=
- True, # bool
- ) # /Constant
- ) # /If
type_ignores=
) # /Module
jgod, jgillard and 243f6a8885a308d313198a2e037
Metadata
Metadata
Assignees
Labels
F: fmtofffmt: off implementationfmt: off implementationT: enhancementNew feature or requestNew feature or request