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:
4646 configuration files, which should be preferred for multi-user projects.
4747- ` pylsp.plugins.black.preview ` : a boolean to enable or disable [ black's ` --preview `
4848 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.
4951
5052# Development
5153
Original file line number Diff line number Diff line change @@ -137,8 +137,8 @@ def _load_config(filename: str, client_config: Config) -> Dict:
137137 "line_length" : settings .get ("line_length" , 88 ),
138138 "fast" : False ,
139139 "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 ) ,
142142 "target_version" : set (),
143143 "preview" : settings .get ("preview" , False ),
144144 }
Original file line number Diff line number Diff line change @@ -41,6 +41,23 @@ def config(workspace):
4141 return cfg
4242
4343
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+
4461@pytest .fixture
4562def unformatted_document (workspace ):
4663 path = fixtures_dir / "unformatted.txt"
@@ -271,6 +288,22 @@ def test_load_config_defaults(config):
271288 }
272289
273290
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+
274307def test_entry_point ():
275308 distribution = pkg_resources .get_distribution ("python-lsp-black" )
276309 entry_point = distribution .get_entry_info ("pylsp" , "pylsp_black" )
You can’t perform that action at this time.
0 commit comments