Skip to content

Commit

Permalink
Go with the version of importlib-metadata that targets the 3.11 sdlib
Browse files Browse the repository at this point in the history
  • Loading branch information
matteius committed Apr 24, 2024
1 parent 6d49721 commit db438fa
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 288 deletions.
334 changes: 104 additions & 230 deletions pipenv/vendor/importlib_metadata/__init__.py

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion pipenv/vendor/importlib_metadata/_adapters.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __iter__(self):
def __getitem__(self, item):
"""
Warn users that a ``KeyError`` can be expected when a
missing key is supplied. Ref python/importlib_metadata#371.
mising key is supplied. Ref python/importlib_metadata#371.
"""
res = super().__getitem__(item)
if res is None:
Expand Down
19 changes: 17 additions & 2 deletions pipenv/vendor/importlib_metadata/_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,14 @@
import platform


__all__ = ['install', 'NullFinder']
__all__ = ['install', 'NullFinder', 'Protocol']


try:
from typing import Protocol
except ImportError: # pragma: no cover
# Python 3.7 compatibility
from pipenv.patched.pip._vendor.typing_extensions import Protocol # type: ignore


def install(cls):
Expand Down Expand Up @@ -38,14 +45,22 @@ def matches(finder):

class NullFinder:
"""
A "Finder" (aka "MetaPathFinder") that never finds any modules,
A "Finder" (aka "MetaClassFinder") that never finds any modules,
but may find distributions.
"""

@staticmethod
def find_spec(*args, **kwargs):
return None

# In Python 2, the import system requires finders
# to have a find_module() method, but this usage
# is deprecated in Python 3 in favor of find_spec().
# For the purposes of this finder (i.e. being present
# on sys.meta_path but having no other import
# system functionality), the two methods are identical.
find_module = find_spec


def pypy_partial(val):
"""
Expand Down
54 changes: 25 additions & 29 deletions pipenv/vendor/importlib_metadata/_meta.py
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
from __future__ import annotations

import os
from typing import Protocol
from ._compat import Protocol
from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload


_T = TypeVar("_T")


class PackageMetadata(Protocol):
def __len__(self) -> int: ... # pragma: no cover
def __len__(self) -> int:
... # pragma: no cover

def __contains__(self, item: str) -> bool: ... # pragma: no cover
def __contains__(self, item: str) -> bool:
... # pragma: no cover

def __getitem__(self, key: str) -> str: ... # pragma: no cover
def __getitem__(self, key: str) -> str:
... # pragma: no cover

def __iter__(self) -> Iterator[str]: ... # pragma: no cover
def __iter__(self) -> Iterator[str]:
... # pragma: no cover

@overload
def get(
self, name: str, failobj: None = None
) -> Optional[str]: ... # pragma: no cover
def get(self, name: str, failobj: None = None) -> Optional[str]:
... # pragma: no cover

@overload
def get(self, name: str, failobj: _T) -> Union[str, _T]: ... # pragma: no cover
def get(self, name: str, failobj: _T) -> Union[str, _T]:
... # pragma: no cover

# overload per python/importlib_metadata#435
@overload
def get_all(
self, name: str, failobj: None = None
) -> Optional[List[Any]]: ... # pragma: no cover
def get_all(self, name: str, failobj: None = None) -> Optional[List[Any]]:
... # pragma: no cover

@overload
def get_all(self, name: str, failobj: _T) -> Union[List[Any], _T]:
Expand All @@ -44,24 +44,20 @@ def json(self) -> Dict[str, Union[str, List[str]]]:
"""


class SimplePath(Protocol):
class SimplePath(Protocol[_T]):
"""
A minimal subset of pathlib.Path required by Distribution.
A minimal subset of pathlib.Path required by PathDistribution.
"""

def joinpath(
self, other: Union[str, os.PathLike[str]]
) -> SimplePath: ... # pragma: no cover
def joinpath(self) -> _T:
... # pragma: no cover

def __truediv__(
self, other: Union[str, os.PathLike[str]]
) -> SimplePath: ... # pragma: no cover
def __truediv__(self, other: Union[str, _T]) -> _T:
... # pragma: no cover

@property
def parent(self) -> SimplePath: ... # pragma: no cover

def read_text(self, encoding=None) -> str: ... # pragma: no cover

def read_bytes(self) -> bytes: ... # pragma: no cover
def parent(self) -> _T:
... # pragma: no cover

def exists(self) -> bool: ... # pragma: no cover
def read_text(self) -> str:
... # pragma: no cover
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
"""
Compatibility layer with Python 3.8/3.9
"""

from typing import TYPE_CHECKING, Any, Optional

if TYPE_CHECKING: # pragma: no cover
# Prevent circular imports on runtime.
from .. import Distribution, EntryPoint
from . import Distribution, EntryPoint
else:
Distribution = EntryPoint = Any

Expand All @@ -18,7 +17,7 @@ def normalized_name(dist: Distribution) -> Optional[str]:
try:
return dist._normalized_name
except AttributeError:
from .. import Prepared # -> delay to prevent circular imports.
from . import Prepared # -> delay to prevent circular imports.

return Prepared.normalize(getattr(dist, "name", None) or dist.metadata['Name'])

Expand All @@ -30,7 +29,7 @@ def ep_matches(ep: EntryPoint, **params) -> bool:
try:
return ep.matches(**params)
except AttributeError:
from .. import EntryPoint # -> delay to prevent circular imports.
from . import EntryPoint # -> delay to prevent circular imports.

# Reconstruct the EntryPoint object to make sure it is compatible.
return EntryPoint(ep.name, ep.value, ep.group).matches(**params)
Empty file.
21 changes: 0 additions & 21 deletions pipenv/vendor/importlib_metadata/diagnose.py

This file was deleted.

2 changes: 1 addition & 1 deletion pipenv/vendor/vendor.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ click-didyoumean==0.3.1
click==8.1.7
colorama==0.4.6
dparse==0.6.3
importlib-metadata==7.1.0
importlib-metadata==6.5.1
pexpect==4.9.0
pipdeptree==2.18.1
plette==0.4.4
Expand Down

0 comments on commit db438fa

Please sign in to comment.