Skip to content

Commit bc56959

Browse files
haploccordoba12
authored andcommitted
Cache black configuration per file
Use lru_cache decorator on load_config to remember the black configuration for each file that the plugin processes. If the black configuration changes for any reason (e.g. the user editing the pyproject.toml file for the project) then the LSP server would need to be restarted for python-lsp-black to refresh the configuration.
1 parent 42005ae commit bc56959

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

pylsp_black/plugin.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import logging
22
import os
3+
from functools import lru_cache
34
from pathlib import Path
45
from typing import Dict, Optional
56

@@ -103,6 +104,7 @@ def format_text(*, text, config):
103104
raise black.NothingChanged from e
104105

105106

107+
@lru_cache(100)
106108
def load_config(filename: str) -> Dict:
107109
defaults = {
108110
"line_length": 88,

0 commit comments

Comments
 (0)