From 68af09493b1d7ef829eb3c0813542c5e21e63ec4 Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Wed, 17 Jan 2024 20:02:21 +0500 Subject: [PATCH 1/4] refactor: add return type for select method --- importlib_metadata/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 09a02a4e..a3aae725 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -275,7 +275,7 @@ def __repr__(self): """ return '%s(%r)' % (self.__class__.__name__, tuple(self)) - def select(self, **params): + def select(self, **params) -> EntryPoints: """ Select entry points from self that match the given parameters (typically group and/or name). From 72b30eca10d73b0f793aac5239e11710077c26cf Mon Sep 17 00:00:00 2001 From: Danyal-Faheem Date: Tue, 30 Jan 2024 15:30:36 +0500 Subject: [PATCH 2/4] refactor: add return type for load method --- importlib_metadata/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index a3aae725..d196ab79 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -33,7 +33,7 @@ from importlib import import_module from importlib.abc import MetaPathFinder from itertools import starmap -from typing import Iterable, List, Mapping, Optional, Set, cast +from typing import Iterable, List, Mapping, Optional, Set, cast, Any __all__ = [ 'Distribution', @@ -175,7 +175,7 @@ class EntryPoint: def __init__(self, name: str, value: str, group: str) -> None: vars(self).update(name=name, value=value, group=group) - def load(self): + def load(self) -> Any: """Load the entry point from its definition. If only a module is indicated by the value, return that module. Otherwise, return the named object. From fd3a0abc127bbd8986958e5baa54f9304daf2fa4 Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 6 Mar 2024 21:50:33 -0500 Subject: [PATCH 3/4] Re-order imports for consistency. --- importlib_metadata/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index d196ab79..3f14faa2 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -33,7 +33,7 @@ from importlib import import_module from importlib.abc import MetaPathFinder from itertools import starmap -from typing import Iterable, List, Mapping, Optional, Set, cast, Any +from typing import Any, Iterable, List, Mapping, Optional, Set, cast __all__ = [ 'Distribution', From 9d4908e77692d915872b24c040d3a1c89ebba1be Mon Sep 17 00:00:00 2001 From: "Jason R. Coombs" Date: Wed, 6 Mar 2024 21:56:41 -0500 Subject: [PATCH 4/4] =?UTF-8?q?=F0=9F=A7=8E=E2=80=8D=E2=99=80=EF=B8=8F=20G?= =?UTF-8?q?enuflect=20to=20the=20types.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- importlib_metadata/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/importlib_metadata/__init__.py b/importlib_metadata/__init__.py index 3f14faa2..5593f74e 100644 --- a/importlib_metadata/__init__.py +++ b/importlib_metadata/__init__.py @@ -33,7 +33,7 @@ from importlib import import_module from importlib.abc import MetaPathFinder from itertools import starmap -from typing import Any, Iterable, List, Mapping, Optional, Set, cast +from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast __all__ = [ 'Distribution', @@ -180,7 +180,7 @@ def load(self) -> Any: is indicated by the value, return that module. Otherwise, return the named object. """ - match = self.pattern.match(self.value) + match = cast(Match, self.pattern.match(self.value)) module = import_module(match.group('module')) attrs = filter(None, (match.group('attr') or '').split('.')) return functools.reduce(getattr, attrs, module) @@ -769,6 +769,7 @@ class Lookup: """ A micro-optimized class for searching a (fast) path for metadata. """ + def __init__(self, path: FastPath): """ Calculate all of the children representing metadata.