summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--isort/settings.py14
-rw-r--r--tests/test_isort.py2
2 files changed, 13 insertions, 3 deletions
diff --git a/isort/settings.py b/isort/settings.py
index 9cdd6c77..8df49461 100644
--- a/isort/settings.py
+++ b/isort/settings.py
@@ -56,12 +56,13 @@ CONFIG_SOURCES: Tuple[str, ...] = (
"tox.ini",
".editorconfig",
)
+
CONFIG_SECTIONS: Dict[str, Tuple[str, ...]] = {
".isort.cfg": ("settings", "isort"),
"pyproject.toml": ("tool.isort",),
"setup.cfg": ("isort", "tool:isort"),
"tox.ini": ("isort", "tool:isort"),
- ".editorconfig": ("*", "*.py", "**.py"),
+ ".editorconfig": ("*", "*.py", "**.py", "*.{py}"),
}
FALLBACK_CONFIG_SECTIONS: Tuple[str, ...] = ("isort", "tool:isort", "tool.isort")
FALLBACK_CONFIGS: Tuple[str, ...]
@@ -426,7 +427,16 @@ def _get_config_data(file_path: str, sections: Iterable[str]) -> Dict[str, Any]:
config = configparser.ConfigParser(strict=False)
config.read_file(config_file)
for section in sections:
- if config.has_section(section):
+ if section.startswith("*.{") and section.endswith("}"):
+ extension = section[len("*.{") : -1]
+ for config_key in config.keys():
+ if config_key.startswith("*.{") and config_key.endswith("}"):
+ if extension in map(
+ lambda text: text.strip(), config_key[len("*.{") : -1].split(",")
+ ):
+ settings.update(config.items(config_key))
+
+ elif config.has_section(section):
settings.update(config.items(section))
if settings:
diff --git a/tests/test_isort.py b/tests/test_isort.py
index 8a53973c..7f6d399a 100644
--- a/tests/test_isort.py
+++ b/tests/test_isort.py
@@ -25,7 +25,7 @@ except ImportError:
toml = None
TEST_DEFAULT_CONFIG = """
-[*.py]
+[*.{py,pyi}]
max_line_length = 120
indent_style = space
indent_size = 4