Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 7 additions & 9 deletions proselint/config/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,16 +77,14 @@ def load_from(config_path: Path | None = None) -> Config:
NOTE: This assumes that a `config_path` is valid if one is provided.
"""
result = DEFAULT
config_paths = paths.config_paths + ([config_path] if config_path else [])

for path in filter(Path.is_file, config_paths):
result = _deepmerge_dicts(
cast("dict[str, object]", result),
json.loads(path.read_text()), # pyright: ignore[reportAny]
config_paths = ([config_path] if config_path else []) + paths.config_paths
try:
result = cast(
"Config",
json.loads(next(filter(Path.is_file, config_paths)).read_text()),
)

result = cast("Config", result)
except StopIteration:
return DEFAULT

return Config(
max_errors=result.get("max_errors", 0),
Expand Down
3 changes: 1 addition & 2 deletions proselint/config/paths.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ def _get_xdg_path(env_var: str, default: Path) -> Path:
config_user_path = _get_xdg_path(XDG_CONFIG_VAR, home_path / ".config")

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