|
45 | 45 | from .wrap_modes import WrapModes
|
46 | 46 | from .wrap_modes import from_string as wrap_mode_from_string
|
47 | 47 |
|
| 48 | +if sys.version_info < (3, 10): |
| 49 | + from importlib_metadata import entry_points |
| 50 | +else: |
| 51 | + from importlib.metadata import entry_points |
| 52 | + |
48 | 53 | if TYPE_CHECKING:
|
49 | 54 | tomllib: Any
|
50 | 55 | else:
|
@@ -356,9 +361,7 @@ def __init__(
|
356 | 361 | profile: Dict[str, Any] = {}
|
357 | 362 | if profile_name:
|
358 | 363 | if profile_name not in profiles:
|
359 |
| - import pkg_resources |
360 |
| - |
361 |
| - for plugin in pkg_resources.iter_entry_points("isort.profiles"): |
| 364 | + for plugin in entry_points(group="isort.profiles"): |
362 | 365 | profiles.setdefault(plugin.name, plugin.load())
|
363 | 366 |
|
364 | 367 | if profile_name not in profiles:
|
@@ -473,9 +476,7 @@ def __init__(
|
473 | 476 | combined_config["src_paths"] = tuple(src_paths)
|
474 | 477 |
|
475 | 478 | if "formatter" in combined_config:
|
476 |
| - import pkg_resources |
477 |
| - |
478 |
| - for plugin in pkg_resources.iter_entry_points("isort.formatters"): |
| 479 | + for plugin in entry_points(group="isort.formatters"): |
479 | 480 | if plugin.name == combined_config["formatter"]:
|
480 | 481 | combined_config["formatting_function"] = plugin.load()
|
481 | 482 | break
|
@@ -715,9 +716,7 @@ def sorting_function(self) -> Callable[..., List[str]]:
|
715 | 716 | self._sorting_function = sorted
|
716 | 717 | else:
|
717 | 718 | available_sort_orders = ["natural", "native"]
|
718 |
| - import pkg_resources |
719 |
| - |
720 |
| - for sort_plugin in pkg_resources.iter_entry_points("isort.sort_function"): |
| 719 | + for sort_plugin in entry_points(group="isort.sort_function"): |
721 | 720 | available_sort_orders.append(sort_plugin.name)
|
722 | 721 | if sort_plugin.name == self.sort_order:
|
723 | 722 | self._sorting_function = sort_plugin.load()
|
|
0 commit comments