File tree Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Expand file tree Collapse file tree 3 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -46,6 +46,8 @@ the valid configuration keys:
46
46
configuration files, which should be preferred for multi-user projects.
47
47
- ` pylsp.plugins.black.preview ` : a boolean to enable or disable [ black's ` --preview `
48
48
setting] ( https://black.readthedocs.io/en/stable/the_black_code_style/future_style.html#preview-style ) .
49
+ - ` pylsp.plugins.black.skip_string_normalization ` : a boolean to enable or disable black's ` --skip-string-normalization ` setting. ` false ` by default.
50
+ - ` pylsp.plugins.black.skip_magic_trailing_comma ` : a boolean to enable or disable black's ` skip-magic-trailing-comma ` setting. ` false ` by default.
49
51
50
52
# Development
51
53
Original file line number Diff line number Diff line change @@ -137,8 +137,8 @@ def _load_config(filename: str, client_config: Config) -> Dict:
137
137
"line_length" : settings .get ("line_length" , 88 ),
138
138
"fast" : False ,
139
139
"pyi" : filename .endswith (".pyi" ),
140
- "skip_string_normalization" : False ,
141
- "skip_magic_trailing_comma" : False ,
140
+ "skip_string_normalization" : settings . get ( "skip_string_normalization" , False ) ,
141
+ "skip_magic_trailing_comma" : settings . get ( "skip_magic_trailing_comma" , False ) ,
142
142
"target_version" : set (),
143
143
"preview" : settings .get ("preview" , False ),
144
144
}
Original file line number Diff line number Diff line change @@ -41,6 +41,23 @@ def config(workspace):
41
41
return cfg
42
42
43
43
44
+ @pytest .fixture
45
+ def config_with_skip_options (workspace ):
46
+ """Return a config object."""
47
+ cfg = Config (workspace .root_uri , {}, 0 , {})
48
+ cfg ._plugin_settings = {
49
+ "plugins" : {
50
+ "black" : {
51
+ "line_length" : 88 ,
52
+ "cache_config" : False ,
53
+ "skip_string_normalization" : True ,
54
+ "skip_magic_trailing_comma" : True ,
55
+ }
56
+ }
57
+ }
58
+ return cfg
59
+
60
+
44
61
@pytest .fixture
45
62
def unformatted_document (workspace ):
46
63
path = fixtures_dir / "unformatted.txt"
@@ -271,6 +288,22 @@ def test_load_config_defaults(config):
271
288
}
272
289
273
290
291
+ def test_load_config_with_skip_options (config_with_skip_options ):
292
+ config = load_config (
293
+ str (fixtures_dir / "skip_options" / "example.py" ), config_with_skip_options
294
+ )
295
+
296
+ assert config == {
297
+ "line_length" : 88 ,
298
+ "target_version" : set (),
299
+ "pyi" : False ,
300
+ "fast" : False ,
301
+ "skip_magic_trailing_comma" : True ,
302
+ "skip_string_normalization" : True ,
303
+ "preview" : False ,
304
+ }
305
+
306
+
274
307
def test_entry_point ():
275
308
distribution = pkg_resources .get_distribution ("python-lsp-black" )
276
309
entry_point = distribution .get_entry_info ("pylsp" , "pylsp_black" )
You can’t perform that action at this time.
0 commit comments