Skip to content

Commit c676669

Browse files
committed
refactor: make importlib metadata package import lazy
No reason I can discern for it, just a matter of traditions I guess. #2405 (comment)
1 parent 05b76ec commit c676669

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

isort/settings.py

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,6 @@
4545
from .wrap_modes import WrapModes
4646
from .wrap_modes import from_string as wrap_mode_from_string
4747

48-
if sys.version_info < (3, 10): # pragma: no cover
49-
from importlib_metadata import entry_points
50-
else:
51-
from importlib.metadata import entry_points
52-
5348
if TYPE_CHECKING:
5449
tomllib: Any
5550
else:
@@ -937,4 +932,17 @@ def _as_bool(value: str) -> bool:
937932
raise ValueError(f"invalid truth value {value}")
938933

939934

935+
def entry_points(**params):
936+
"""Call entry_point after lazy loading it.
937+
938+
TODO: The reason for lazy loading here are unknown.
939+
"""
940+
if sys.version_info < (3, 10): # pragma: no cover
941+
from importlib_metadata import entry_points
942+
else:
943+
from importlib.metadata import entry_points
944+
945+
return entry_points(**params)
946+
947+
940948
DEFAULT_CONFIG = Config()

0 commit comments

Comments
 (0)