Skip to content

Commit 2eaab85

Browse files
committed
refactor(config)!: stop searching after config file is found
BREAKING CHANGE: This removes the previous implicit merging behaviour. Configuration that relied on this behaviour will need to be modified to include the merged-in values.
1 parent 6a4fbf8 commit 2eaab85

File tree

2 files changed

+8
-11
lines changed

2 files changed

+8
-11
lines changed

proselint/config/__init__.py

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -77,16 +77,14 @@ def load_from(config_path: Path | None = None) -> Config:
7777
7878
NOTE: This assumes that a `config_path` is valid if one is provided.
7979
"""
80-
result = DEFAULT
81-
config_paths = paths.config_paths + ([config_path] if config_path else [])
82-
83-
for path in filter(Path.is_file, config_paths):
84-
result = _deepmerge_dicts(
85-
cast("dict[str, object]", result),
86-
json.loads(path.read_text()), # pyright: ignore[reportAny]
80+
config_paths = ([config_path] if config_path else []) + paths.config_paths
81+
try:
82+
result = cast(
83+
"Config",
84+
json.loads(next(filter(Path.is_file, config_paths)).read_text()),
8785
)
88-
89-
result = cast("Config", result)
86+
except StopIteration:
87+
return DEFAULT
9088

9189
return Config(
9290
max_errors=result.get("max_errors", 0),

proselint/config/paths.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ def _get_xdg_path(env_var: str, default: Path) -> Path:
2020
config_user_path = _get_xdg_path(XDG_CONFIG_VAR, home_path / ".config")
2121

2222
config_paths = [
23-
# NOTE: This is in reverse priority order - the order config gets merged in
24-
config_user_path / "proselint" / "config.json",
2523
cwd / "proselint.json",
24+
config_user_path / "proselint" / "config.json",
2625
]

0 commit comments

Comments
 (0)