Skip to content

Commit 65e6cd1

Browse files
committed
Clear sqlfluff extra_config cache when it's been modified
1 parent 3053326 commit 65e6cd1

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

src/dbt_core_interface/project.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6215,9 +6215,9 @@ def lint_sql(
62156215
if request.query.get("extra_config_path")
62166216
else None
62176217
),
6218-
config_last_modification=(
6219-
request.query.get("config_last_modification")
6220-
if request.query.get("config_last_modification")
6218+
extra_config_last_modification=(
6219+
request.query.get("extra_config_last_modification")
6220+
if request.query.get("extra_config_last_modification")
62216221
else None
62226222
),
62236223
)

src/dbt_core_interface/sqlfluff_util.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
def get_linter(
1515
config: FluffConfig,
1616
stream: FileOutput,
17-
config_last_modification: Optional[str] = None,
1817
):
1918
"""Get linter."""
2019
from sqlfluff.cli.commands import get_linter_and_formatter
@@ -28,7 +27,7 @@ def get_config(
2827
dbt_project_root: Path,
2928
extra_config_path: Optional[Path] = None,
3029
ignore_local_config: bool = False,
31-
config_last_modification: Optional[str] = None,
30+
extra_config_last_modification: Optional[str] = None,
3231
require_dialect: bool = True,
3332
**kwargs,
3433
) -> FluffConfig:
@@ -41,6 +40,9 @@ def get_config(
4140
overrides = {k: kwargs[k] for k in kwargs if kwargs[k] is not None}
4241
loader = ConfigLoader.get_global()
4342

43+
if extra_config_last_modification:
44+
loader._config_cache.pop(str(extra_config_path), {})
45+
4446
# Load config at project root
4547
base_config = loader.load_config_up_to_path(
4648
path=str(dbt_project_root),
@@ -61,15 +63,15 @@ def get_config(
6163
stream = FileOutput(config, os.devnull)
6264
atexit.register(stream.close)
6365

64-
return config, stream, config_last_modification
66+
return config, stream
6567

6668

6769
def lint_command(
6870
project_root: Path,
6971
sql: Union[Path, str],
7072
extra_config_path: Optional[Path] = None,
7173
ignore_local_config: bool = False,
72-
config_last_modification: Optional[str] = None,
74+
extra_config_last_modification: Optional[str] = None,
7375
) -> Optional[Dict]:
7476
"""Lint specified file or SQL string.
7577
@@ -91,7 +93,7 @@ def lint_command(
9193
project_root,
9294
extra_config_path,
9395
ignore_local_config,
94-
config_last_modification,
96+
extra_config_last_modification,
9597
require_dialect=False,
9698
nocolor=True,
9799
)

0 commit comments

Comments
 (0)