diff options
| author | AlexSm <[email protected]> | 2024-01-09 18:56:40 +0100 |
|---|---|---|
| committer | GitHub <[email protected]> | 2024-01-09 18:56:40 +0100 |
| commit | e95f266d2a3e48e62015220588a4fd73d5d5a5cb (patch) | |
| tree | a8a784b6931fe52ad5f511cfef85af14e5f63991 /contrib/python/importlib-metadata/py3 | |
| parent | 50a65e3b48a82d5b51f272664da389f2e0b0c99a (diff) | |
Library import 6 (#888)
Diffstat (limited to 'contrib/python/importlib-metadata/py3')
6 files changed, 65 insertions, 38 deletions
diff --git a/contrib/python/importlib-metadata/py3/.dist-info/METADATA b/contrib/python/importlib-metadata/py3/.dist-info/METADATA index a344859f174..c2bab66615d 100644 --- a/contrib/python/importlib-metadata/py3/.dist-info/METADATA +++ b/contrib/python/importlib-metadata/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: importlib-metadata -Version: 7.0.0 +Version: 7.0.1 Summary: Read metadata from Python packages Home-page: https://github.com/python/importlib_metadata Author: Jason R. Coombs @@ -42,7 +42,7 @@ Requires-Dist: importlib-resources >=1.3 ; (python_version < "3.9") and extra == .. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg -.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg +.. image:: https://github.com/python/importlib_metadata/actions/workflows/main.yml/badge.svg :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22 :alt: tests @@ -82,6 +82,8 @@ were contributed to different versions in the standard library: * - importlib_metadata - stdlib + * - 7.0 + - 3.13 * - 6.5 - 3.12 * - 4.13 diff --git a/contrib/python/importlib-metadata/py3/README.rst b/contrib/python/importlib-metadata/py3/README.rst index 73ddc5fab43..6788a7e3d35 100644 --- a/contrib/python/importlib-metadata/py3/README.rst +++ b/contrib/python/importlib-metadata/py3/README.rst @@ -3,7 +3,7 @@ .. image:: https://img.shields.io/pypi/pyversions/importlib_metadata.svg -.. image:: https://github.com/python/importlib_metadata/workflows/tests/badge.svg +.. image:: https://github.com/python/importlib_metadata/actions/workflows/main.yml/badge.svg :target: https://github.com/python/importlib_metadata/actions?query=workflow%3A%22tests%22 :alt: tests @@ -43,6 +43,8 @@ were contributed to different versions in the standard library: * - importlib_metadata - stdlib + * - 7.0 + - 3.13 * - 6.5 - 3.12 * - 4.13 diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py index cd015707b1a..4debbecb9d8 100644 --- a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py +++ b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py @@ -1,3 +1,5 @@ +from __future__ import annotations + import os import re import abc @@ -20,7 +22,6 @@ from . import _adapters, _meta, _py39compat from ._collections import FreezableDefaultDict, Pair from ._compat import ( NullFinder, - StrPath, install, ) from ._functools import method_cache, pass_none @@ -320,14 +321,12 @@ class PackagePath(pathlib.PurePosixPath): dist: "Distribution" def read_text(self, encoding: str = 'utf-8') -> str: # type: ignore[override] - with self.locate().open(encoding=encoding) as stream: - return stream.read() + return self.locate().read_text(encoding=encoding) def read_binary(self) -> bytes: - with self.locate().open('rb') as stream: - return stream.read() + return self.locate().read_bytes() - def locate(self) -> pathlib.Path: + def locate(self) -> SimplePath: """Return a path-like object for this path""" return self.dist.locate_file(self) @@ -341,6 +340,7 @@ class FileHash: class DeprecatedNonAbstract: + # Required until Python 3.14 def __new__(cls, *args, **kwargs): all_names = { name for subclass in inspect.getmro(cls) for name in vars(subclass) @@ -360,20 +360,42 @@ class DeprecatedNonAbstract: class Distribution(DeprecatedNonAbstract): - """A Python distribution package.""" + """ + An abstract Python distribution package. + + Custom providers may derive from this class and define + the abstract methods to provide a concrete implementation + for their environment. + """ @abc.abstractmethod def read_text(self, filename) -> Optional[str]: """Attempt to load metadata file given by the name. + Python distribution metadata is organized by blobs of text + typically represented as "files" in the metadata directory + (e.g. package-1.0.dist-info). These files include things + like: + + - METADATA: The distribution metadata including fields + like Name and Version and Description. + - entry_points.txt: A series of entry points defined by + the Setuptools spec in an ini format with sections + representing the groups. + - RECORD: A record of files as installed by a typical + installer. + + A package may provide any set of files, including those + not listed here or none at all. + :param filename: The name of the file in the distribution info. :return: The text if found, otherwise None. """ @abc.abstractmethod - def locate_file(self, path: StrPath) -> pathlib.Path: + def locate_file(self, path: str | os.PathLike[str]) -> SimplePath: """ - Given a path to a file in this distribution, return a path + Given a path to a file in this distribution, return a SimplePath to it. """ @@ -396,16 +418,18 @@ class Distribution(DeprecatedNonAbstract): raise PackageNotFoundError(name) @classmethod - def discover(cls, **kwargs) -> Iterable["Distribution"]: + def discover( + cls, *, context: Optional['DistributionFinder.Context'] = None, **kwargs + ) -> Iterable["Distribution"]: """Return an iterable of Distribution objects for all packages. Pass a ``context`` or pass keyword arguments for constructing a context. :context: A ``DistributionFinder.Context`` object. - :return: Iterable of Distribution objects for all packages. + :return: Iterable of Distribution objects for packages matching + the context. """ - context = kwargs.pop('context', None) if context and kwargs: raise ValueError("cannot accept context and kwargs") context = context or DistributionFinder.Context(**kwargs) @@ -414,8 +438,8 @@ class Distribution(DeprecatedNonAbstract): ) @staticmethod - def at(path: StrPath) -> "Distribution": - """Return a Distribution for the indicated metadata path + def at(path: str | os.PathLike[str]) -> "Distribution": + """Return a Distribution for the indicated metadata path. :param path: a string or path-like object :return: a concrete Distribution instance for the path @@ -424,7 +448,7 @@ class Distribution(DeprecatedNonAbstract): @staticmethod def _discover_resolvers(): - """Search the meta_path for resolvers.""" + """Search the meta_path for resolvers (MetadataPathFinders).""" declared = ( getattr(finder, 'find_distributions', None) for finder in sys.meta_path ) @@ -822,7 +846,7 @@ class PathDistribution(Distribution): """ self._path = path - def read_text(self, filename: StrPath) -> Optional[str]: + def read_text(self, filename: str | os.PathLike[str]) -> Optional[str]: with suppress( FileNotFoundError, IsADirectoryError, @@ -836,7 +860,7 @@ class PathDistribution(Distribution): read_text.__doc__ = Distribution.read_text.__doc__ - def locate_file(self, path: StrPath) -> pathlib.Path: + def locate_file(self, path: str | os.PathLike[str]) -> SimplePath: return self._path.parent / path @property diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py b/contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py index a48b609be6c..1a3578e60fb 100644 --- a/contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py +++ b/contrib/python/importlib-metadata/py3/importlib_metadata/_compat.py @@ -1,9 +1,6 @@ -import os import sys import platform -from typing import Union - __all__ = ['install', 'NullFinder'] @@ -44,7 +41,7 @@ def disable_stdlib_finder(): class NullFinder: """ - A "Finder" (aka "MetaClassFinder") that never finds any modules, + A "Finder" (aka "MetaPathFinder") that never finds any modules, but may find distributions. """ @@ -61,10 +58,3 @@ def pypy_partial(val): """ is_pypy = platform.python_implementation() == 'PyPy' return val + is_pypy - - -if sys.version_info >= (3, 9): - StrPath = Union[str, os.PathLike[str]] -else: - # PathLike is only subscriptable at runtime in 3.9+ - StrPath = Union[str, "os.PathLike[str]"] # pragma: no cover diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/_meta.py b/contrib/python/importlib-metadata/py3/importlib_metadata/_meta.py index f670016de7f..1342d839bae 100644 --- a/contrib/python/importlib-metadata/py3/importlib_metadata/_meta.py +++ b/contrib/python/importlib-metadata/py3/importlib_metadata/_meta.py @@ -1,3 +1,6 @@ +from __future__ import annotations + +import os from typing import Protocol from typing import Any, Dict, Iterator, List, Optional, TypeVar, Union, overload @@ -44,20 +47,26 @@ class PackageMetadata(Protocol): """ -class SimplePath(Protocol[_T]): +class SimplePath(Protocol): """ - A minimal subset of pathlib.Path required by PathDistribution. + A minimal subset of pathlib.Path required by Distribution. """ - def joinpath(self, other: Union[str, _T]) -> _T: + def joinpath(self, other: Union[str, os.PathLike[str]]) -> SimplePath: ... # pragma: no cover - def __truediv__(self, other: Union[str, _T]) -> _T: + def __truediv__(self, other: Union[str, os.PathLike[str]]) -> SimplePath: ... # pragma: no cover @property - def parent(self) -> _T: + 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 read_text(self) -> str: + def exists(self) -> bool: ... # pragma: no cover diff --git a/contrib/python/importlib-metadata/py3/ya.make b/contrib/python/importlib-metadata/py3/ya.make index 4e4813824c9..f967f7b41bc 100644 --- a/contrib/python/importlib-metadata/py3/ya.make +++ b/contrib/python/importlib-metadata/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(7.0.0) +VERSION(7.0.1) LICENSE(Apache-2.0) |
