From 25b714541ecdff532274b6b945ed9e74fcb60682 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dani=C3=ABl=20van=20Noord?= <13665637+DanielNoord@users.noreply.github.com> Date: Thu, 23 Jul 2026 21:34:52 +0200 Subject: [PATCH] Avoid a circular import --- isort/settings.py | 4 +++- isort/sorting.py | 7 ++----- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/isort/settings.py b/isort/settings.py index c75697fcf..02ebfe20b 100644 --- a/isort/settings.py +++ b/isort/settings.py @@ -19,7 +19,7 @@ from typing import Any from warnings import warn -from . import sorting, stdlibs +from . import stdlibs from .exceptions import ( FormattingPluginDoesNotExist, InvalidSettingsPath, @@ -675,6 +675,8 @@ def sorting_function(self) -> Callable[..., list[str]]: return self._sorting_function if self.sort_order == "natural": + from . import sorting # noqa: PLC0415 # Circular import... + self._sorting_function = sorting.naturally elif self.sort_order == "native": self._sorting_function = sorted diff --git a/isort/sorting.py b/isort/sorting.py index cb42b1595..1476a5de0 100644 --- a/isort/sorting.py +++ b/isort/sorting.py @@ -1,11 +1,8 @@ import re from collections.abc import Callable, Iterable -from typing import TYPE_CHECKING, Any +from typing import Any -if TYPE_CHECKING: - from .settings import Config -else: - Config = Any +from .settings import Config _import_line_intro_re = re.compile("^(?:from|import) ") _import_line_midline_import_re = re.compile(" import ")