Skip to content

Commit 9279db4

Browse files
committed
Fix entrypoints iteration in Python 3.9
Signed-off-by: Facundo Tuesca <facundo.tuesca@trailofbits.com>
1 parent d5b3da5 commit 9279db4

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/pip/_internal/utils/plugins.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import contextlib
22
import logging
3-
from importlib.metadata import EntryPoints, entry_points
3+
from importlib.metadata import EntryPoint, entry_points
44
from pathlib import Path
55
from typing import Iterator, List
66

@@ -10,12 +10,14 @@
1010
_loaded_plugins: List[Plugin] = []
1111

1212

13-
def iter_entry_points(group_name: str) -> EntryPoints:
13+
def iter_entry_points(group_name: str) -> List[EntryPoint]:
14+
# Only Python >= 3.10 supports the `EntryPoints` class, so we return
15+
# a list of `EntryPoint` instead.
1416
groups = entry_points()
1517
if hasattr(groups, "select"):
1618
# New interface in Python 3.10 and newer versions of the
1719
# importlib_metadata backport.
18-
return groups.select(group=group_name)
20+
return list(groups.select(group=group_name))
1921
else:
2022
assert hasattr(groups, "get")
2123
# Older interface, deprecated in Python 3.10 and recent

0 commit comments

Comments
 (0)