Skip to content

Commit

Permalink
Make entry point collections (more) immutable.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaraco committed Feb 16, 2021
1 parent 342a94b commit 9448e13
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions importlib_metadata/__init__.py
Expand Up @@ -157,9 +157,11 @@ def __reduce__(self):

class EntryPoints(tuple):
"""
A collection of EntryPoint objects, retrievable by name.
An immutable collection of EntryPoint objects, retrievable by name.
"""

__slots__ = ()

def __getitem__(self, name) -> EntryPoint:
try:
return next(ep for ep in self if ep.name == name)
Expand All @@ -173,9 +175,11 @@ def names(self):

class GroupedEntryPoints(tuple):
"""
A collection of EntryPoint objects, retrievable by group.
An immutable collection of EntryPoint objects, retrievable by group.
"""

__slots__ = ()

def __getitem__(self, group) -> EntryPoints:
return EntryPoints(ep for ep in self if ep.group == group)

Expand Down

0 comments on commit 9448e13

Please sign in to comment.