Skip to content

Commit 750455b

Browse files
committed
Make cache_config option False per review
1 parent 4c1b699 commit 750455b

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

pylsp_black/plugin.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ def load_config(filename: str, client_config: Config) -> Dict:
196196
settings = client_config.plugin_settings("black")
197197

198198
# Use the original, not cached function to load settings if requested
199-
if not settings.get("cache_config", True):
199+
if not settings.get("cache_config", False):
200200
return _load_config.__wrapped__(filename, client_config)
201201

202202
return _load_config(filename, client_config)

tests/test_plugin.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def config(workspace):
3636
"""Return a config object."""
3737
cfg = Config(workspace.root_uri, {}, 0, {})
3838
cfg._plugin_settings = {
39-
"plugins": {"black": {"line_length": 88, "cache_config": True}}
39+
"plugins": {"black": {"line_length": 88, "cache_config": False}}
4040
}
4141
return cfg
4242

@@ -313,16 +313,15 @@ def test_pylsp_format_line_length(
313313

314314

315315
def test_cache_config(config, unformatted_document):
316-
# Cache should be working by default
316+
# Cache should be off by default
317317
for _ in range(5):
318318
pylsp_format_document(config, unformatted_document)
319-
assert _load_config.cache_info().hits == 4
319+
assert _load_config.cache_info().hits == 0
320320

321-
# Clear cache and disable it
322-
_load_config.cache_clear()
323-
config.update({"plugins": {"black": {"cache_config": False}}})
321+
# Enable cache
322+
config.update({"plugins": {"black": {"cache_config": True}}})
324323

325-
# Cache should not be working now
324+
# Cache should be working now
326325
for _ in range(5):
327326
pylsp_format_document(config, unformatted_document)
328-
assert _load_config.cache_info().hits == 0
327+
assert _load_config.cache_info().hits == 4

0 commit comments

Comments
 (0)