Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix config overriding with --resolve-all-configs #2119

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions isort/main.py
Expand Up @@ -1111,15 +1111,15 @@ def main(argv: Optional[Sequence[str]] = None, stdin: Optional[TextIOWrapper] =
all_attempt_broken = False
no_valid_encodings = False

config_trie: Optional[Trie] = None
if resolve_all_configs:
config_trie = find_all_configs(config_dict.pop("config_root", "."))

if "src_paths" in config_dict:
config_dict["src_paths"] = {
Path(src_path).resolve() for src_path in config_dict.get("src_paths", ())
}

config_trie: Optional[Trie] = None
if resolve_all_configs:
config_trie = find_all_configs(config_dict.pop("config_root", "."), config_dict)

config = Config(**config_dict)
if show_config:
print(json.dumps(config.__dict__, indent=4, separators=(",", ": "), default=_preconvert))
Expand Down
3 changes: 2 additions & 1 deletion isort/settings.py
Expand Up @@ -798,7 +798,7 @@ def _find_config(path: str) -> Tuple[str, Dict[str, Any]]:
return (path, {})


def find_all_configs(path: str) -> Trie:
def find_all_configs(path: str, config_overrides: Dict[str, Any]) -> Trie:
"""
Looks for config files in the path provided and in all of its sub-directories.
Parses and stores any config file encountered in a trie and returns the root of
Expand All @@ -820,6 +820,7 @@ def find_all_configs(path: str) -> Trie:
config_data = {}

if config_data:
config_data.update(config_overrides)
trie_root.insert(potential_config_file, config_data)
break

Expand Down