From cd807c4cb4de790a53879167af5358c77a01bbd2 Mon Sep 17 00:00:00 2001 From: jaydesl Date: Wed, 21 Oct 2020 18:27:49 +0100 Subject: [PATCH] Always append missing default sections --- isort/settings.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/isort/settings.py b/isort/settings.py index 553475e93..bd8b556bc 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -381,9 +381,11 @@ 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( @@ -391,6 +393,12 @@ def __init__( "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"] = (