From 066e24d79994c69424ecdb51f7048d6e466fc392 Mon Sep 17 00:00:00 2001 From: Amund Hov Date: Wed, 11 Oct 2023 14:45:35 +0200 Subject: [PATCH] With commit 0c819641d314ac496eb32b55f2b15215fa6fa55f the behavior of Entrypoints gets a bit disorienting. Change __repr__ to reflect that Entrpoints is are longer indexable by integers like tuples, but signal our custom behavior. --- importlib_metadata/__init__.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 6ba414e5..bc8714b8 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -293,6 +293,14 @@ def __getitem__(self, name: str) -> EntryPoint: # type: ignore[override] except StopIteration: raise KeyError(name) + def __repr__(self): + """ + Repr with classname and tuple constructor to + signal that we deviate from regular tuple behavior. + """ + return '%s(%r)' % (self.__class__.__name__, tuple(self)) + + def select(self, **params): """ Select entry points from self that match the