Skip to content

Commit

Permalink
Fix entrypoints iteration in Python 3.9
Browse files Browse the repository at this point in the history
Signed-off-by: Facundo Tuesca <[email protected]>
  • Loading branch information
facutuesca committed Oct 29, 2024
1 parent d5b3da5 commit 9279db4
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/pip/_internal/utils/plugins.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import contextlib
import logging
from importlib.metadata import EntryPoints, entry_points
from importlib.metadata import EntryPoint, entry_points
from pathlib import Path
from typing import Iterator, List

Expand All @@ -10,12 +10,14 @@
_loaded_plugins: List[Plugin] = []


def iter_entry_points(group_name: str) -> EntryPoints:
def iter_entry_points(group_name: str) -> List[EntryPoint]:
# Only Python >= 3.10 supports the `EntryPoints` class, so we return
# a list of `EntryPoint` instead.
groups = entry_points()
if hasattr(groups, "select"):
# New interface in Python 3.10 and newer versions of the
# importlib_metadata backport.
return groups.select(group=group_name)
return list(groups.select(group=group_name))
else:
assert hasattr(groups, "get")
# Older interface, deprecated in Python 3.10 and recent
Expand Down

0 comments on commit 9279db4

Please sign in to comment.