Skip to content

Commit 2d9ca1a

Browse files
authored
Merge pull request #6 from dbarrosop/patch-1
Added support for skip-numeric-underscore-normalization
2 parents 371f669 + 50a0169 commit 2d9ca1a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

pyls_black/plugin.py

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

3535
try:
3636
formatted_text = format_text(text=text, config=config)
37-
except (ValueError, black.NothingChanged):
37+
except (ValueError, black.NothingChanged, IndentationError, AssertionError):
3838
return []
3939

4040
return [{"range": range, "newText": formatted_text}]
@@ -47,6 +47,9 @@ def format_text(*, text, config):
4747
py36=config["py36"],
4848
pyi=config["pyi"],
4949
skip_string_normalization=config["skip_string_normalization"],
50+
skip_numeric_underscore_normalization=config[
51+
"skip_numeric_underscore_normalization"
52+
],
5053
)
5154
return black.format_file_contents(
5255
text, line_length=line_length, fast=fast, mode=mode
@@ -60,6 +63,7 @@ def load_config(filename: str) -> Dict:
6063
"py36": False,
6164
"pyi": False,
6265
"skip_string_normalization": False,
66+
"skip_numeric_underscore_normalization": False,
6367
}
6468

6569
root = black.find_project_root((filename,))

tests/fixtures/config/pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,4 @@ line-length = 20
44
py36 = true
55
pyi = true
66
skip-string-normalization = true
7+
skip-numeric-underscore-normalization = true

tests/test_plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ def test_load_config():
133133
"pyi": True,
134134
"fast": True,
135135
"skip_string_normalization": True,
136+
"skip_numeric_underscore_normalization": True,
136137
}
137138

138139

@@ -145,4 +146,5 @@ def test_load_config_defaults():
145146
"pyi": False,
146147
"fast": False,
147148
"skip_string_normalization": False,
149+
"skip_numeric_underscore_normalization": False,
148150
}

0 commit comments

Comments
 (0)