|
33 | 33 | from importlib import import_module |
34 | 34 | from importlib.abc import MetaPathFinder |
35 | 35 | from itertools import starmap |
36 | | -from typing import Iterable, List, Mapping, Optional, Set, cast |
| 36 | +from typing import Any, Iterable, List, Mapping, Match, Optional, Set, cast |
37 | 37 |
|
38 | 38 | __all__ = [ |
39 | 39 | 'Distribution', |
@@ -175,12 +175,12 @@ class EntryPoint: |
175 | 175 | def __init__(self, name: str, value: str, group: str) -> None: |
176 | 176 | vars(self).update(name=name, value=value, group=group) |
177 | 177 |
|
178 | | - def load(self): |
| 178 | + def load(self) -> Any: |
179 | 179 | """Load the entry point from its definition. If only a module |
180 | 180 | is indicated by the value, return that module. Otherwise, |
181 | 181 | return the named object. |
182 | 182 | """ |
183 | | - match = self.pattern.match(self.value) |
| 183 | + match = cast(Match, self.pattern.match(self.value)) |
184 | 184 | module = import_module(match.group('module')) |
185 | 185 | attrs = filter(None, (match.group('attr') or '').split('.')) |
186 | 186 | return functools.reduce(getattr, attrs, module) |
@@ -275,7 +275,7 @@ def __repr__(self): |
275 | 275 | """ |
276 | 276 | return '%s(%r)' % (self.__class__.__name__, tuple(self)) |
277 | 277 |
|
278 | | - def select(self, **params): |
| 278 | + def select(self, **params) -> EntryPoints: |
279 | 279 | """ |
280 | 280 | Select entry points from self that match the |
281 | 281 | given parameters (typically group and/or name). |
|
0 commit comments