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.