|
27 | 27 | import time
|
28 | 28 | import re
|
29 | 29 | import types
|
30 |
| -from typing import List, Protocol |
| 30 | +from typing import Dict, List, Protocol |
31 | 31 | import zipfile
|
32 | 32 | import zipimport
|
33 | 33 | import warnings
|
@@ -920,10 +920,10 @@ def find_plugins(self, plugin_env, full_env=None, installer=None, fallback=True)
|
920 | 920 | # success, no need to try any more versions of this project
|
921 | 921 | break
|
922 | 922 |
|
923 |
| - distributions = list(distributions) |
924 |
| - distributions.sort() |
| 923 | + sorted_distributions = list(distributions) |
| 924 | + sorted_distributions.sort() |
925 | 925 |
|
926 |
| - return distributions, error_info |
| 926 | + return sorted_distributions, error_info |
927 | 927 |
|
928 | 928 | def require(self, *requirements):
|
929 | 929 | """Ensure that distributions matching `requirements` are activated
|
@@ -1636,7 +1636,7 @@ def _validate_resource_path(path):
|
1636 | 1636 | )
|
1637 | 1637 |
|
1638 | 1638 | def _get(self, path) -> bytes:
|
1639 |
| - if hasattr(self.loader, 'get_data'): |
| 1639 | + if self.loader and hasattr(self.loader, 'get_data'): |
1640 | 1640 | return self.loader.get_data(path)
|
1641 | 1641 | raise NotImplementedError(
|
1642 | 1642 | "Can't perform this operation for loaders without 'get_data()'"
|
@@ -2492,7 +2492,7 @@ def resolve(self):
|
2492 | 2492 | raise ImportError(str(exc)) from exc
|
2493 | 2493 |
|
2494 | 2494 | def require(self, env=None, installer=None):
|
2495 |
| - if self.extras and not self.dist: |
| 2495 | + if not self.dist: |
2496 | 2496 | raise UnknownExtra("Can't require() without a distribution", self)
|
2497 | 2497 |
|
2498 | 2498 | # Get the requirements for this entry point with all its extras and
|
@@ -2559,11 +2559,11 @@ def parse_group(cls, group, lines, dist=None):
|
2559 | 2559 | def parse_map(cls, data, dist=None):
|
2560 | 2560 | """Parse a map of entry point groups"""
|
2561 | 2561 | if isinstance(data, dict):
|
2562 |
| - data = data.items() |
| 2562 | + _data = data.items() |
2563 | 2563 | else:
|
2564 |
| - data = split_sections(data) |
2565 |
| - maps = {} |
2566 |
| - for group, lines in data: |
| 2564 | + _data = split_sections(data) |
| 2565 | + maps: Dict[str, Dict[str, "EntryPoint"]] = {} |
| 2566 | + for group, lines in _data: |
2567 | 2567 | if group is None:
|
2568 | 2568 | if not lines:
|
2569 | 2569 | continue
|
@@ -2825,7 +2825,7 @@ def activate(self, path=None, replace=False):
|
2825 | 2825 | if path is None:
|
2826 | 2826 | path = sys.path
|
2827 | 2827 | self.insert_on(path, replace=replace)
|
2828 |
| - if path is sys.path: |
| 2828 | + if path is sys.path and self.location: |
2829 | 2829 | fixup_namespace_packages(self.location)
|
2830 | 2830 | for pkg in self._get_metadata('namespace_packages.txt'):
|
2831 | 2831 | if pkg in sys.modules:
|
@@ -2893,15 +2893,13 @@ def load_entry_point(self, group, name):
|
2893 | 2893 |
|
2894 | 2894 | def get_entry_map(self, group=None):
|
2895 | 2895 | """Return the entry point map for `group`, or the full entry map"""
|
2896 |
| - try: |
2897 |
| - ep_map = self._ep_map |
2898 |
| - except AttributeError: |
2899 |
| - ep_map = self._ep_map = EntryPoint.parse_map( |
| 2896 | + if not hasattr(self, "_ep_map"): |
| 2897 | + self._ep_map = EntryPoint.parse_map( |
2900 | 2898 | self._get_metadata('entry_points.txt'), self
|
2901 | 2899 | )
|
2902 | 2900 | if group is not None:
|
2903 |
| - return ep_map.get(group, {}) |
2904 |
| - return ep_map |
| 2901 | + return self._ep_map.get(group, {}) |
| 2902 | + return self._ep_map |
2905 | 2903 |
|
2906 | 2904 | def get_entry_info(self, group, name):
|
2907 | 2905 | """Return the EntryPoint object for `group`+`name`, or ``None``"""
|
|
0 commit comments