Skip to content

Commit 7c3143a

Browse files
authored
Merge pull request #10 from rupert/document-exceptions
Document exceptions raised by black
2 parents 2d9ca1a + a2c5e60 commit 7c3143a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

pyls_black/plugin.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,16 @@ def format_document(document, range=None):
3434

3535
try:
3636
formatted_text = format_text(text=text, config=config)
37-
except (ValueError, black.NothingChanged, IndentationError, AssertionError):
37+
except (
38+
ValueError,
39+
# raised when the file is already formatted correctly
40+
black.NothingChanged,
41+
# raised when the file being formatted has an indentation error
42+
IndentationError,
43+
# raised when black produces invalid Python code or formats the file
44+
# differently on the second pass
45+
AssertionError,
46+
):
3847
return []
3948

4049
return [{"range": range, "newText": formatted_text}]

0 commit comments

Comments
 (0)