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

Always append missing default sections #1571

Closed
wants to merge 1 commit into from
Closed
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
12 changes: 10 additions & 2 deletions isort/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -381,16 +381,24 @@ def __init__(

combined_config[key] = type(default_value)(value)

for section in combined_config.get("sections", ()):
missing_sections = list(SECTION_DEFAULTS)
defined_sections = combined_config.get("sections", ())
for section in defined_sections:
if section in SECTION_DEFAULTS:
continue
missing_sections.remove(section)
elif not section.lower() in known_other:
config_keys = ", ".join(known_other.keys())
warn(
f"`sections` setting includes {section}, but no known_{section.lower()} "
"is defined. "
f"The following known_SECTION config options are defined: {config_keys}."
)
if defined_sections and missing_sections:
combined_config["sections"] = defined_sections + tuple(missing_sections)
warn(
"`sections` setting was defined without the default sections "
f"{tuple(missing_sections)}. These have now been appended."
)

if "directory" not in combined_config:
combined_config["directory"] = (
Expand Down