Skip to content

Commit a3ad5f7

Browse files
committed
Extract '_unique' for identifying unique distributions.
1 parent 2df8b5a commit a3ad5f7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

importlib_metadata/__init__.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,6 +1015,15 @@ def version(distribution_name):
10151015
return distribution(distribution_name).version
10161016

10171017

1018+
_unique = functools.partial(
1019+
unique_everseen,
1020+
key=operator.attrgetter('_normalized_name'),
1021+
)
1022+
"""
1023+
Wrapper for ``distributions`` to return unique distributions by name.
1024+
"""
1025+
1026+
10181027
def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
10191028
"""Return EntryPoint objects for all installed packages.
10201029
@@ -1032,10 +1041,8 @@ def entry_points(**params) -> Union[EntryPoints, SelectableGroups]:
10321041
10331042
:return: EntryPoints or SelectableGroups for all installed packages.
10341043
"""
1035-
norm_name = operator.attrgetter('_normalized_name')
1036-
unique = functools.partial(unique_everseen, key=norm_name)
10371044
eps = itertools.chain.from_iterable(
1038-
dist.entry_points for dist in unique(distributions())
1045+
dist.entry_points for dist in _unique(distributions())
10391046
)
10401047
return SelectableGroups.load(eps).select(**params)
10411048

0 commit comments

Comments
 (0)