summaryrefslogtreecommitdiffstats
path: root/contrib/python
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2026-04-06 10:43:03 +0300
committerrobot-piglet <[email protected]>2026-04-06 11:08:49 +0300
commit22277522ff3f9295d391f792e24519b5524e08e7 (patch)
treeb716dd50b1ac52509ca4d033dadcdba2624ffdc3 /contrib/python
parent6c3bc7d565d0724cfc19b940667d9511b1ce1704 (diff)
Intermediate changes
commit_hash:c148ad6a0b118c22f7657f45ff68f0664429aaa0
Diffstat (limited to 'contrib/python')
-rw-r--r--contrib/python/importlib-metadata/py3/.dist-info/METADATA11
-rw-r--r--contrib/python/importlib-metadata/py3/LICENSE2
-rw-r--r--contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py6
-rw-r--r--contrib/python/importlib-metadata/py3/importlib_metadata/_functools.py3
-rw-r--r--contrib/python/importlib-metadata/py3/importlib_metadata/compat/py39.py42
-rw-r--r--contrib/python/importlib-metadata/py3/ya.make3
-rw-r--r--contrib/python/jaraco.context/.dist-info/METADATA9
-rw-r--r--contrib/python/jaraco.context/jaraco/context/__init__.py147
-rw-r--r--contrib/python/jaraco.context/ya.make2
9 files changed, 122 insertions, 103 deletions
diff --git a/contrib/python/importlib-metadata/py3/.dist-info/METADATA b/contrib/python/importlib-metadata/py3/.dist-info/METADATA
index 4cfa3bc1284..98dfda37bc4 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.4
Name: importlib_metadata
-Version: 8.7.1
+Version: 8.8.0
Summary: Read metadata from Python packages
Author-email: "Jason R. Coombs" <[email protected]>
License-Expression: Apache-2.0
@@ -9,16 +9,14 @@ Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
-Requires-Python: >=3.9
+Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest!=8.1.*,>=6; extra == "test"
Requires-Dist: packaging; extra == "test"
Requires-Dist: pyfakefs; extra == "test"
-Requires-Dist: flufl.flake8; extra == "test"
Requires-Dist: pytest-perf>=0.9.2; extra == "test"
-Requires-Dist: jaraco.test>=5.4; extra == "test"
Provides-Extra: doc
Requires-Dist: sphinx>=3.5; extra == "doc"
Requires-Dist: jaraco.packaging>=9.3; extra == "doc"
@@ -29,15 +27,14 @@ Requires-Dist: jaraco.tidelift>=1.4; extra == "doc"
Provides-Extra: perf
Requires-Dist: ipython; extra == "perf"
Provides-Extra: check
-Requires-Dist: pytest-checkdocs>=2.4; extra == "check"
+Requires-Dist: pytest-checkdocs>=2.14; extra == "check"
Requires-Dist: pytest-ruff>=0.2.1; sys_platform != "cygwin" and extra == "check"
Provides-Extra: cover
Requires-Dist: pytest-cov; extra == "cover"
Provides-Extra: enabler
Requires-Dist: pytest-enabler>=3.4; extra == "enabler"
Provides-Extra: type
-Requires-Dist: pytest-mypy>=1.0.1; extra == "type"
-Requires-Dist: mypy<1.19; platform_python_implementation == "PyPy" and extra == "type"
+Requires-Dist: pytest-mypy>=1.0.1; platform_python_implementation != "PyPy" and extra == "type"
Dynamic: license-file
.. image:: https://img.shields.io/pypi/v/importlib_metadata.svg
diff --git a/contrib/python/importlib-metadata/py3/LICENSE b/contrib/python/importlib-metadata/py3/LICENSE
index 5c1d8bbc02a..7b25cfb85f1 100644
--- a/contrib/python/importlib-metadata/py3/LICENSE
+++ b/contrib/python/importlib-metadata/py3/LICENSE
@@ -58,7 +58,7 @@ APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a file or class name and description of purpose be included on the same "printed page" as the copyright notice for easier identification within third-party archives.
-Copyright 2025 [name of copyright owner]
+Copyright 2026 [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
index 57af32cd1ff..46d8b7c5ac2 100644
--- a/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
+++ b/contrib/python/importlib-metadata/py3/importlib_metadata/__init__.py
@@ -39,7 +39,7 @@ from ._functools import method_cache, noop, pass_none, passthrough
from ._itertools import always_iterable, bucket, unique_everseen
from ._meta import PackageMetadata, SimplePath
from ._typing import md_none
-from .compat import py39, py311
+from .compat import py311
__all__ = [
'Distribution',
@@ -346,7 +346,7 @@ class EntryPoints(tuple):
Select entry points from self that match the
given parameters (typically group and/or name).
"""
- return EntryPoints(ep for ep in self if py39.ep_matches(ep, **params))
+ return EntryPoints(ep for ep in self if ep.matches(**params))
@property
def names(self) -> set[str]:
@@ -1147,7 +1147,7 @@ def version(distribution_name: str) -> str:
_unique = functools.partial(
unique_everseen,
- key=py39.normalized_name,
+ key=operator.attrgetter('_normalized_name'),
)
"""
Wrapper for ``distributions`` to return unique distributions by name.
diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/_functools.py b/contrib/python/importlib-metadata/py3/importlib_metadata/_functools.py
index b1fd04a84ab..c159b46e489 100644
--- a/contrib/python/importlib-metadata/py3/importlib_metadata/_functools.py
+++ b/contrib/python/importlib-metadata/py3/importlib_metadata/_functools.py
@@ -1,6 +1,7 @@
import functools
import types
-from typing import Callable, TypeVar
+from collections.abc import Callable
+from typing import TypeVar
# from jaraco.functools 3.3
diff --git a/contrib/python/importlib-metadata/py3/importlib_metadata/compat/py39.py b/contrib/python/importlib-metadata/py3/importlib_metadata/compat/py39.py
deleted file mode 100644
index 3eb9c01ecbb..00000000000
--- a/contrib/python/importlib-metadata/py3/importlib_metadata/compat/py39.py
+++ /dev/null
@@ -1,42 +0,0 @@
-"""
-Compatibility layer with Python 3.8/3.9
-"""
-
-from __future__ import annotations
-
-from typing import TYPE_CHECKING, Any
-
-if TYPE_CHECKING: # pragma: no cover
- # Prevent circular imports on runtime.
- from .. import Distribution, EntryPoint
-else:
- Distribution = EntryPoint = Any
-
-from .._typing import md_none
-
-
-def normalized_name(dist: Distribution) -> str | None:
- """
- Honor name normalization for distributions that don't provide ``_normalized_name``.
- """
- try:
- return dist._normalized_name
- except AttributeError:
- from .. import Prepared # -> delay to prevent circular imports.
-
- return Prepared.normalize(
- getattr(dist, "name", None) or md_none(dist.metadata)['Name']
- )
-
-
-def ep_matches(ep: EntryPoint, **params) -> bool:
- """
- Workaround for ``EntryPoint`` objects without the ``matches`` method.
- """
- try:
- return ep.matches(**params)
- except AttributeError:
- 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)
diff --git a/contrib/python/importlib-metadata/py3/ya.make b/contrib/python/importlib-metadata/py3/ya.make
index 95d8468d861..2f053d3c048 100644
--- a/contrib/python/importlib-metadata/py3/ya.make
+++ b/contrib/python/importlib-metadata/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(8.7.1)
+VERSION(8.8.0)
LICENSE(Apache-2.0)
@@ -21,7 +21,6 @@ PY_SRCS(
importlib_metadata/_typing.py
importlib_metadata/compat/__init__.py
importlib_metadata/compat/py311.py
- importlib_metadata/compat/py39.py
importlib_metadata/diagnose.py
)
diff --git a/contrib/python/jaraco.context/.dist-info/METADATA b/contrib/python/jaraco.context/.dist-info/METADATA
index fb61c50e237..19462179a60 100644
--- a/contrib/python/jaraco.context/.dist-info/METADATA
+++ b/contrib/python/jaraco.context/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.4
Name: jaraco.context
-Version: 6.1.1
+Version: 6.1.2
Summary: Useful decorators and context managers
Author-email: "Jason R. Coombs" <[email protected]>
License-Expression: MIT
@@ -9,7 +9,7 @@ Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
-Requires-Python: >=3.9
+Requires-Python: >=3.10
Description-Content-Type: text/x-rst
License-File: LICENSE
Requires-Dist: backports.tarfile; python_version < "3.12"
@@ -25,15 +25,14 @@ Requires-Dist: furo; extra == "doc"
Requires-Dist: sphinx-lint; extra == "doc"
Requires-Dist: jaraco.tidelift>=1.4; extra == "doc"
Provides-Extra: check
-Requires-Dist: pytest-checkdocs>=2.4; extra == "check"
+Requires-Dist: pytest-checkdocs>=2.14; extra == "check"
Requires-Dist: pytest-ruff>=0.2.1; sys_platform != "cygwin" and extra == "check"
Provides-Extra: cover
Requires-Dist: pytest-cov; extra == "cover"
Provides-Extra: enabler
Requires-Dist: pytest-enabler>=3.4; extra == "enabler"
Provides-Extra: type
-Requires-Dist: pytest-mypy>=1.0.1; extra == "type"
-Requires-Dist: mypy<1.19; platform_python_implementation == "PyPy" and extra == "type"
+Requires-Dist: pytest-mypy>=1.0.1; platform_python_implementation != "PyPy" and extra == "type"
Dynamic: license-file
.. image:: https://img.shields.io/pypi/v/jaraco.context.svg
diff --git a/contrib/python/jaraco.context/jaraco/context/__init__.py b/contrib/python/jaraco.context/jaraco/context/__init__.py
index a286dff75c1..42f91d13e23 100644
--- a/contrib/python/jaraco.context/jaraco/context/__init__.py
+++ b/contrib/python/jaraco.context/jaraco/context/__init__.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import builtins
import contextlib
import errno
import functools
@@ -12,16 +13,44 @@ import subprocess
import sys
import tempfile
import urllib.request
-from collections.abc import Iterator
+from collections.abc import Callable, Generator, Iterator
+from types import TracebackType
+from typing import (
+ TYPE_CHECKING,
+ Literal,
+ TypeVar,
+ cast,
+)
-if sys.version_info < (3, 12):
- from backports import tarfile
+# jaraco/backports.tarfile#1
+if TYPE_CHECKING or sys.version_info >= (3, 12):
+ import tarfile # pragma: no cover
else:
- import tarfile
+ from backports import tarfile # pragma: no cover
+
+if TYPE_CHECKING:
+ from typing import TypeAlias
+
+ from _typeshed import FileDescriptorOrPath, OptExcInfo, StrPath
+ from typing_extensions import ParamSpec, Self, Unpack
+
+ _FileDescriptorOrPathT = TypeVar(
+ "_FileDescriptorOrPathT", bound=FileDescriptorOrPath
+ )
+ _P = ParamSpec("_P")
+
+_UnpackableOptExcInfo: TypeAlias = tuple[
+ type[BaseException] | None,
+ BaseException | None,
+ TracebackType | None,
+]
+_R = TypeVar("_R")
+_T1_co = TypeVar("_T1_co", covariant=True)
+_T2_co = TypeVar("_T2_co", covariant=True)
@contextlib.contextmanager
-def pushd(dir: str | os.PathLike) -> Iterator[str | os.PathLike]:
+def pushd(dir: StrPath) -> Iterator[StrPath]:
"""
>>> tmp_path = getfixture('tmp_path')
>>> with pushd(tmp_path):
@@ -38,9 +67,7 @@ def pushd(dir: str | os.PathLike) -> Iterator[str | os.PathLike]:
@contextlib.contextmanager
-def tarball(
- url, target_dir: str | os.PathLike | None = None
-) -> Iterator[str | os.PathLike]:
+def tarball(url: str, target_dir: StrPath | None = None) -> Iterator[StrPath]:
"""
Get a URL to a tarball, download, extract, yield, then clean up.
@@ -83,8 +110,8 @@ def tarball(
shutil.rmtree(target_dir)
-def _compose_tarfile_filters(*filters):
- def compose_two(f1, f2):
+def _compose_tarfile_filters(*filters): # type: ignore[no-untyped-def]
+ def compose_two(f1, f2): # type: ignore[no-untyped-def]
return lambda member, path: f1(f2(member, path), path)
return functools.reduce(compose_two, filters, lambda member, path: member)
@@ -92,16 +119,24 @@ def _compose_tarfile_filters(*filters):
def strip_first_component(
member: tarfile.TarInfo,
- path,
+ path: object,
) -> tarfile.TarInfo:
_, member.name = member.name.split('/', 1)
return member
-_default_filter = _compose_tarfile_filters(tarfile.data_filter, strip_first_component)
+_default_filter = _compose_tarfile_filters(tarfile.data_filter, strip_first_component) # type: ignore[no-untyped-call]
-def _compose(*cmgrs):
+def _compose(
+ *cmgrs: Unpack[
+ tuple[
+ # Flipped from compose_two because of reverse
+ Callable[[_T1_co], contextlib.AbstractContextManager[_T2_co]],
+ Callable[_P, contextlib.AbstractContextManager[_T1_co]],
+ ]
+ ],
+) -> Callable[_P, contextlib._GeneratorContextManager[_T2_co]]:
"""
Compose any number of dependent context managers into a single one.
@@ -121,14 +156,21 @@ def _compose(*cmgrs):
... assert os.path.samefile(os.getcwd(), dir)
"""
- def compose_two(inner, outer):
- def composed(*args, **kwargs):
+ def compose_two(
+ inner: Callable[_P, contextlib.AbstractContextManager[_T1_co]],
+ outer: Callable[[_T1_co], contextlib.AbstractContextManager[_T2_co]],
+ ) -> Callable[_P, contextlib._GeneratorContextManager[_T2_co]]:
+ def composed(*args: _P.args, **kwargs: _P.kwargs) -> Generator[_T2_co]:
with inner(*args, **kwargs) as saved, outer(saved) as res:
yield res
return contextlib.contextmanager(composed)
- return functools.reduce(compose_two, reversed(cmgrs))
+ # reversed makes cmgrs no longer variadic, breaking type validation
+ # Mypy infers compose_two as Callable[[function, function], function]. See:
+ # - https://github.com/python/typeshed/issues/7580
+ # - https://github.com/python/mypy/issues/8240
+ return functools.reduce(compose_two, reversed(cmgrs)) # type: ignore[return-value, arg-type]
tarball_cwd = _compose(pushd, tarball)
@@ -137,7 +179,11 @@ A tarball context with the current working directory pointing to the contents.
"""
-def remove_readonly(func, path, exc_info):
+def remove_readonly(
+ func: Callable[[_FileDescriptorOrPathT], object],
+ path: _FileDescriptorOrPathT,
+ exc_info: tuple[object, OSError, object],
+) -> None:
"""
Add support for removing read-only files on Windows.
"""
@@ -151,16 +197,20 @@ def remove_readonly(func, path, exc_info):
raise
-def robust_remover():
+def robust_remover() -> Callable[..., None]:
return (
- functools.partial(shutil.rmtree, onerror=remove_readonly)
+ functools.partial(
+ # cast for python/mypy#18637 / python/mypy#17585
+ cast("Callable[..., None]", shutil.rmtree),
+ onerror=remove_readonly,
+ )
if platform.system() == 'Windows'
else shutil.rmtree
)
@contextlib.contextmanager
-def temp_dir(remover=shutil.rmtree):
+def temp_dir(remover: Callable[[str], object] = shutil.rmtree) -> Generator[str]:
"""
Create a temporary directory context. Pass a custom remover
to override the removal behavior.
@@ -182,8 +232,11 @@ robust_temp_dir = functools.partial(temp_dir, remover=robust_remover())
@contextlib.contextmanager
def repo_context(
- url, branch: str | None = None, quiet: bool = True, dest_ctx=robust_temp_dir
-):
+ url: str,
+ branch: str | None = None,
+ quiet: bool = True,
+ dest_ctx: Callable[[], contextlib.AbstractContextManager[str]] = robust_temp_dir,
+) -> Generator[str]:
"""
Check out the repo indicated by url.
@@ -201,7 +254,7 @@ def repo_context(
exe = 'git' if 'git' in url else 'hg'
with dest_ctx() as repo_dir:
cmd = [exe, 'clone', url, repo_dir]
- cmd.extend(['--branch', branch] * bool(branch))
+ cmd.extend(['--branch', branch] * bool(branch)) # type: ignore[list-item]
stream = subprocess.DEVNULL if quiet else None
subprocess.check_call(cmd, stdout=stream, stderr=stream)
yield repo_dir
@@ -241,37 +294,42 @@ class ExceptionTrap:
False
"""
- exc_info = None, None, None
+ exc_info: OptExcInfo = None, None, None
- def __init__(self, exceptions=(Exception,)):
+ def __init__(self, exceptions: tuple[type[BaseException], ...] = (Exception,)):
self.exceptions = exceptions
- def __enter__(self):
+ def __enter__(self) -> Self:
return self
@property
- def type(self):
+ def type(self) -> type[BaseException] | None:
return self.exc_info[0]
@property
- def value(self):
+ def value(self) -> BaseException | None:
return self.exc_info[1]
@property
- def tb(self):
+ def tb(self) -> TracebackType | None:
return self.exc_info[2]
- def __exit__(self, *exc_info):
- type = exc_info[0]
- matches = type and issubclass(type, self.exceptions)
+ def __exit__(
+ self,
+ *exc_info: Unpack[_UnpackableOptExcInfo], # noqa: PYI036 # We can do better than object
+ ) -> builtins.type[BaseException] | None | bool:
+ exc_type = exc_info[0]
+ matches = exc_type and issubclass(exc_type, self.exceptions)
if matches:
- self.exc_info = exc_info
+ self.exc_info = exc_info # type: ignore[assignment]
return matches
- def __bool__(self):
+ def __bool__(self) -> bool:
return bool(self.type)
- def raises(self, func, *, _test=bool):
+ def raises(
+ self, func: Callable[_P, _R], *, _test: Callable[[ExceptionTrap], bool] = bool
+ ) -> functools._Wrapped[_P, _R, _P, bool]:
"""
Wrap func and replace the result with the truth
value of the trap (True if an exception occurred).
@@ -286,14 +344,14 @@ class ExceptionTrap:
"""
@functools.wraps(func)
- def wrapper(*args, **kwargs):
+ def wrapper(*args: _P.args, **kwargs: _P.kwargs) -> bool:
with ExceptionTrap(self.exceptions) as trap:
func(*args, **kwargs)
return _test(trap)
return wrapper
- def passes(self, func):
+ def passes(self, func: Callable[_P, _R]) -> functools._Wrapped[_P, _R, _P, bool]:
"""
Wrap func and replace the result with the truth
value of the trap (True if no exception).
@@ -342,16 +400,23 @@ class on_interrupt(contextlib.ContextDecorator):
... on_interrupt('ignore')(do_interrupt)()
"""
- def __init__(self, action='error', /, code=1):
+ def __init__(
+ self, action: Literal['ignore', 'suppress', 'error'] = 'error', /, code: int = 1
+ ):
self.action = action
self.code = code
- def __enter__(self):
+ def __enter__(self) -> Self:
return self
- def __exit__(self, exctype, excinst, exctb):
+ def __exit__(
+ self,
+ exctype: type[BaseException] | None,
+ excinst: BaseException | None,
+ exctb: TracebackType | None,
+ ) -> None | bool:
if exctype is not KeyboardInterrupt or self.action == 'ignore':
- return
+ return None
elif self.action == 'error':
raise SystemExit(self.code) from excinst
return self.action == 'suppress'
diff --git a/contrib/python/jaraco.context/ya.make b/contrib/python/jaraco.context/ya.make
index 77072d68a4e..149318265c1 100644
--- a/contrib/python/jaraco.context/ya.make
+++ b/contrib/python/jaraco.context/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.1.1)
+VERSION(6.1.2)
LICENSE(MIT)