diff options
| author | robot-piglet <[email protected]> | 2026-02-20 11:53:58 +0300 |
|---|---|---|
| committer | robot-piglet <[email protected]> | 2026-02-20 12:23:47 +0300 |
| commit | d1e282f75c7e8d47bd0616b646650271dbbb8485 (patch) | |
| tree | 26c9f0fdd953554132e25be8c1e4d01364acc9a1 /contrib/python | |
| parent | e6b7c5cee7e65333f260ee22d015419020617e51 (diff) | |
Intermediate changes
commit_hash:e00964d6590dd56f8c1aa3c7f6aee608119963af
Diffstat (limited to 'contrib/python')
19 files changed, 116 insertions, 64 deletions
diff --git a/contrib/python/pip/.dist-info/METADATA b/contrib/python/pip/.dist-info/METADATA index d6eace3996e..e56d5d1f85d 100644 --- a/contrib/python/pip/.dist-info/METADATA +++ b/contrib/python/pip/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: pip -Version: 26.0 +Version: 26.0.1 Summary: The PyPA recommended tool for installing Python packages. Author-email: The pip developers <[email protected]> Requires-Python: >=3.9 diff --git a/contrib/python/pip/pip/__init__.py b/contrib/python/pip/pip/__init__.py index d34dc69b4e3..978b4129206 100644 --- a/contrib/python/pip/pip/__init__.py +++ b/contrib/python/pip/pip/__init__.py @@ -1,6 +1,6 @@ from __future__ import annotations -__version__ = "26.0" +__version__ = "26.0.1" def main(args: list[str] | None = None) -> int: diff --git a/contrib/python/pip/pip/_internal/req/req_file.py b/contrib/python/pip/pip/_internal/req/req_file.py index 10f138c895b..9eb58ce665b 100644 --- a/contrib/python/pip/pip/_internal/req/req_file.py +++ b/contrib/python/pip/pip/_internal/req/req_file.py @@ -283,7 +283,9 @@ def handle_option_line( opts.release_control.all_releases.add(":all:") if opts.release_control: - finder.set_release_control(opts.release_control) + if not finder.release_control: + # First time seeing release_control, set it on finder + finder.set_release_control(opts.release_control) if opts.prefer_binary: finder.set_prefer_binary() @@ -440,6 +442,7 @@ def get_line_parser(finder: PackageFinder | None) -> LineParser: defaults.index_url = None if finder: defaults.format_control = finder.format_control + defaults.release_control = finder.release_control args_str, options_str = break_args_options(line) diff --git a/contrib/python/pip/ya.make b/contrib/python/pip/ya.make index a94d77ff1e0..a28cd22e7d7 100644 --- a/contrib/python/pip/ya.make +++ b/contrib/python/pip/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(26.0) +VERSION(26.0.1) LICENSE(MIT) diff --git a/contrib/python/tenacity/py3/.dist-info/METADATA b/contrib/python/tenacity/py3/.dist-info/METADATA index 8fa59d2b13f..288891709df 100644 --- a/contrib/python/tenacity/py3/.dist-info/METADATA +++ b/contrib/python/tenacity/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.4 Name: tenacity -Version: 9.1.2 +Version: 9.1.3 Summary: Retry code until it succeeds Home-page: https://github.com/jd/tenacity Author: Julien Danjou @@ -11,13 +11,13 @@ Classifier: License :: OSI Approved :: Apache Software License Classifier: Programming Language :: Python Classifier: Programming Language :: Python :: 3 Classifier: Programming Language :: Python :: 3 :: Only -Classifier: Programming Language :: Python :: 3.9 Classifier: Programming Language :: Python :: 3.10 Classifier: Programming Language :: Python :: 3.11 Classifier: Programming Language :: Python :: 3.12 Classifier: Programming Language :: Python :: 3.13 +Classifier: Programming Language :: Python :: 3.14 Classifier: Topic :: Utilities -Requires-Python: >=3.9 +Requires-Python: >=3.10 License-File: LICENSE Provides-Extra: doc Requires-Dist: reno; extra == "doc" diff --git a/contrib/python/tenacity/py3/README.rst b/contrib/python/tenacity/py3/README.rst index 928ddd99b91..6a5b66bb947 100644 --- a/contrib/python/tenacity/py3/README.rst +++ b/contrib/python/tenacity/py3/README.rst @@ -637,17 +637,3 @@ Contribute #. Make the docs better (or more detailed, or more easier to read, or ...) .. _`the repository`: https://github.com/jd/tenacity - -Changelogs -~~~~~~~~~~ - -`reno`_ is used for managing changelogs. Take a look at their usage docs. - -The doc generation will automatically compile the changelogs. You just need to add them. - -.. code-block:: sh - - # Opens a template file in an editor - tox -e reno -- new some-slug-for-my-change --edit - -.. _`reno`: https://docs.openstack.org/reno/latest/user/usage.html diff --git a/contrib/python/tenacity/py3/tenacity/__init__.py b/contrib/python/tenacity/py3/tenacity/__init__.py index e274c215575..e734d6f563e 100644 --- a/contrib/python/tenacity/py3/tenacity/__init__.py +++ b/contrib/python/tenacity/py3/tenacity/__init__.py @@ -59,6 +59,7 @@ from .stop import stop_when_event_set # noqa # Import all built-in wait strategies for easier usage. from .wait import wait_chain # noqa from .wait import wait_combine # noqa +from .wait import wait_exception # noqa from .wait import wait_exponential # noqa from .wait import wait_fixed # noqa from .wait import wait_incrementing # noqa @@ -98,14 +99,11 @@ if t.TYPE_CHECKING: WrappedFnReturnT = t.TypeVar("WrappedFnReturnT") WrappedFn = t.TypeVar("WrappedFn", bound=t.Callable[..., t.Any]) +P = t.ParamSpec("P") +R = t.TypeVar("R") -dataclass_kwargs = {} -if sys.version_info >= (3, 10): - dataclass_kwargs.update({"slots": True}) - - [email protected](**dataclass_kwargs) [email protected](slots=True) class IterState: actions: t.List[t.Callable[["RetryCallState"], t.Any]] = dataclasses.field( default_factory=list @@ -307,19 +305,15 @@ class BaseRetrying(ABC): future we may provide a way to aggregate the various statistics from each thread). """ - try: - return self._local.statistics # type: ignore[no-any-return] - except AttributeError: + if not hasattr(self._local, "statistics"): self._local.statistics = t.cast(t.Dict[str, t.Any], {}) - return self._local.statistics + return self._local.statistics # type: ignore[no-any-return] @property def iter_state(self) -> IterState: - try: - return self._local.iter_state # type: ignore[no-any-return] - except AttributeError: + if not hasattr(self._local, "iter_state"): self._local.iter_state = IterState() - return self._local.iter_state + return self._local.iter_state # type: ignore[no-any-return] def wraps(self, f: WrappedFn) -> WrappedFn: """Wrap a function for retrying. @@ -489,13 +483,7 @@ class Retrying(BaseRetrying): return do # type: ignore[no-any-return] -if sys.version_info >= (3, 9): - FutureGenericT = futures.Future[t.Any] -else: - FutureGenericT = futures.Future - - -class Future(FutureGenericT): +class Future(futures.Future[t.Any]): """Encapsulates a (future or past) attempted call to a target function.""" def __init__(self, attempt_number: int) -> None: @@ -603,7 +591,27 @@ def retry(func: WrappedFn) -> WrappedFn: ... @t.overload def retry( - sleep: t.Callable[[t.Union[int, float]], t.Union[None, t.Awaitable[None]]] = sleep, + *, + sleep: t.Callable[[t.Union[int, float]], t.Awaitable[None]], + stop: "StopBaseT" = ..., + wait: "WaitBaseT" = ..., + retry: "t.Union[RetryBaseT, tasyncio.retry.RetryBaseT]" = ..., + before: t.Callable[["RetryCallState"], t.Union[None, t.Awaitable[None]]] = ..., + after: t.Callable[["RetryCallState"], t.Union[None, t.Awaitable[None]]] = ..., + before_sleep: t.Optional[ + t.Callable[["RetryCallState"], t.Union[None, t.Awaitable[None]]] + ] = ..., + reraise: bool = ..., + retry_error_cls: t.Type["RetryError"] = ..., + retry_error_callback: t.Optional[ + t.Callable[["RetryCallState"], t.Union[t.Any, t.Awaitable[t.Any]]] + ] = ..., +) -> t.Callable[[t.Callable[P, R | t.Awaitable[R]]], t.Callable[P, t.Awaitable[R]]]: ... + + +def retry( + sleep: t.Callable[[t.Union[int, float]], None] = sleep, stop: "StopBaseT" = stop_never, wait: "WaitBaseT" = wait_none(), retry: "t.Union[RetryBaseT, tasyncio.retry.RetryBaseT]" = retry_if_exception_type(), @@ -642,7 +650,10 @@ def retry(*dargs: t.Any, **dkw: t.Any) -> t.Any: f"this will probably hang indefinitely (did you mean retry={f.__class__.__name__}(...)?)" ) r: "BaseRetrying" - if _utils.is_coroutine_callable(f): + sleep = dkw.get("sleep") + if _utils.is_coroutine_callable(f) or ( + sleep is not None and _utils.is_coroutine_callable(sleep) + ): r = AsyncRetrying(*dargs, **dkw) elif ( tornado @@ -690,6 +701,7 @@ __all__ = [ "stop_when_event_set", "wait_chain", "wait_combine", + "wait_exception", "wait_exponential", "wait_fixed", "wait_incrementing", diff --git a/contrib/python/tenacity/py3/tenacity/_utils.py b/contrib/python/tenacity/py3/tenacity/_utils.py index f11a088814d..be148719b59 100644 --- a/contrib/python/tenacity/py3/tenacity/_utils.py +++ b/contrib/python/tenacity/py3/tenacity/_utils.py @@ -25,6 +25,18 @@ from datetime import timedelta MAX_WAIT = sys.maxsize / 2 +class LoggerProtocol(typing.Protocol): + """ + Protocol used by utils expecting a logger (eg: before_log). + + Compatible with logging, structlog, loguru, etc... + """ + + def log( + self, level: int, msg: str, /, *args: typing.Any, **kwargs: typing.Any + ) -> typing.Any: ... + + def find_ordinal(pos_num: int) -> str: # See: https://en.wikipedia.org/wiki/English_numerals#Ordinal_numbers if pos_num == 0: diff --git a/contrib/python/tenacity/py3/tenacity/after.py b/contrib/python/tenacity/py3/tenacity/after.py index aa3cc9df0c2..a4b892241c9 100644 --- a/contrib/python/tenacity/py3/tenacity/after.py +++ b/contrib/python/tenacity/py3/tenacity/after.py @@ -19,8 +19,6 @@ import typing from tenacity import _utils if typing.TYPE_CHECKING: - import logging - from tenacity import RetryCallState @@ -29,9 +27,9 @@ def after_nothing(retry_state: "RetryCallState") -> None: def after_log( - logger: "logging.Logger", + logger: _utils.LoggerProtocol, log_level: int, - sec_format: str = "%0.3f", + sec_format: str = "%.3g", ) -> typing.Callable[["RetryCallState"], None]: """After call strategy that logs to some logger the finished attempt.""" diff --git a/contrib/python/tenacity/py3/tenacity/asyncio/__init__.py b/contrib/python/tenacity/py3/tenacity/asyncio/__init__.py index a92609140e5..230b115460b 100644 --- a/contrib/python/tenacity/py3/tenacity/asyncio/__init__.py +++ b/contrib/python/tenacity/py3/tenacity/asyncio/__init__.py @@ -107,11 +107,15 @@ class AsyncRetrying(BaseRetrying): self.begin() retry_state = RetryCallState(retry_object=self, fn=fn, args=args, kwargs=kwargs) + is_async = _utils.is_coroutine_callable(fn) while True: do = await self.iter(retry_state=retry_state) if isinstance(do, DoAttempt): try: - result = await fn(*args, **kwargs) + if is_async: + result = await fn(*args, **kwargs) + else: + result = fn(*args, **kwargs) except BaseException: # noqa: B902 retry_state.set_exception(sys.exc_info()) # type: ignore[arg-type] else: diff --git a/contrib/python/tenacity/py3/tenacity/before.py b/contrib/python/tenacity/py3/tenacity/before.py index 366235af6af..5d9aa24ec51 100644 --- a/contrib/python/tenacity/py3/tenacity/before.py +++ b/contrib/python/tenacity/py3/tenacity/before.py @@ -19,8 +19,6 @@ import typing from tenacity import _utils if typing.TYPE_CHECKING: - import logging - from tenacity import RetryCallState @@ -29,7 +27,7 @@ def before_nothing(retry_state: "RetryCallState") -> None: def before_log( - logger: "logging.Logger", log_level: int + logger: _utils.LoggerProtocol, log_level: int ) -> typing.Callable[["RetryCallState"], None]: """Before call strategy that logs to some logger the attempt.""" diff --git a/contrib/python/tenacity/py3/tenacity/before_sleep.py b/contrib/python/tenacity/py3/tenacity/before_sleep.py index 153edb7acbb..a822cb86397 100644 --- a/contrib/python/tenacity/py3/tenacity/before_sleep.py +++ b/contrib/python/tenacity/py3/tenacity/before_sleep.py @@ -19,8 +19,6 @@ import typing from tenacity import _utils if typing.TYPE_CHECKING: - import logging - from tenacity import RetryCallState @@ -29,9 +27,10 @@ def before_sleep_nothing(retry_state: "RetryCallState") -> None: def before_sleep_log( - logger: "logging.Logger", + logger: _utils.LoggerProtocol, log_level: int, exc_info: bool = False, + sec_format: str = "%.3g", ) -> typing.Callable[["RetryCallState"], None]: """Before sleep strategy that logs to some logger the attempt.""" @@ -65,7 +64,7 @@ def before_sleep_log( logger.log( log_level, f"Retrying {fn_name} " - f"in {retry_state.next_action.sleep} seconds as it {verb} {value}.", + f"in {sec_format % retry_state.next_action.sleep} seconds as it {verb} {value}.", exc_info=local_exc_info, ) diff --git a/contrib/python/tenacity/py3/tenacity/tornadoweb.py b/contrib/python/tenacity/py3/tenacity/tornadoweb.py index 44323e40dab..a0aa64914a9 100644 --- a/contrib/python/tenacity/py3/tenacity/tornadoweb.py +++ b/contrib/python/tenacity/py3/tenacity/tornadoweb.py @@ -37,7 +37,7 @@ class TornadoRetrying(BaseRetrying): super().__init__(**kwargs) self.sleep = sleep - @gen.coroutine # type: ignore[misc] + @gen.coroutine # type: ignore[untyped-decorator] def __call__( self, fn: "typing.Callable[..., typing.Union[typing.Generator[typing.Any, typing.Any, _RetValT], Future[_RetValT]]]", diff --git a/contrib/python/tenacity/py3/tenacity/wait.py b/contrib/python/tenacity/py3/tenacity/wait.py index dc3c8505ac4..1cc17ea2042 100644 --- a/contrib/python/tenacity/py3/tenacity/wait.py +++ b/contrib/python/tenacity/py3/tenacity/wait.py @@ -98,10 +98,10 @@ class wait_chain(wait_base): @retry(wait=wait_chain(*[wait_fixed(1) for i in range(3)] + [wait_fixed(2) for j in range(5)] + - [wait_fixed(5) for k in range(4))) + [wait_fixed(5) for k in range(4)])) def wait_chained(): - print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s - thereafter.") + print("Wait 1s for 3 attempts, 2s for 5 attempts and 5s " + "thereafter.") """ def __init__(self, *strategies: wait_base) -> None: @@ -113,6 +113,45 @@ class wait_chain(wait_base): return wait_func(retry_state=retry_state) +class wait_exception(wait_base): + """Wait strategy that waits the amount of time returned by the predicate. + + The predicate is passed the exception object. Based on the exception, the + user can decide how much time to wait before retrying. + + For example:: + + def http_error(exception: BaseException) -> float: + if ( + isinstance(exception, requests.HTTPError) + and exception.response.status_code == requests.codes.too_many_requests + ): + return float(exception.response.headers.get("Retry-After", "1")) + return 60.0 + + + @retry( + stop=stop_after_attempt(3), + wait=wait_exception(http_error), + ) + def http_get_request(url: str) -> None: + response = requests.get(url) + response.raise_for_status() + """ + + def __init__(self, predicate: typing.Callable[[BaseException], float]) -> None: + self.predicate = predicate + + def __call__(self, retry_state: "RetryCallState") -> float: + if retry_state.outcome is None: + raise RuntimeError("__call__() called before outcome was set") + + exception = retry_state.outcome.exception() + if exception is None: + raise RuntimeError("outcome failed but the exception is None") + return self.predicate(exception) + + class wait_incrementing(wait_base): """Wait an incremental amount of time after each attempt. diff --git a/contrib/python/tenacity/py3/ya.make b/contrib/python/tenacity/py3/ya.make index 56cf178d140..1e3032d4fe1 100644 --- a/contrib/python/tenacity/py3/ya.make +++ b/contrib/python/tenacity/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(9.1.2) +VERSION(9.1.3) LICENSE(Apache-2.0) diff --git a/contrib/python/ydb/py3/.dist-info/METADATA b/contrib/python/ydb/py3/.dist-info/METADATA index 65593309207..62b51c5ce30 100644 --- a/contrib/python/ydb/py3/.dist-info/METADATA +++ b/contrib/python/ydb/py3/.dist-info/METADATA @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: ydb -Version: 3.26.4 +Version: 3.26.5 Summary: YDB Python SDK Home-page: http://github.com/ydb-platform/ydb-python-sdk Author: Yandex LLC diff --git a/contrib/python/ydb/py3/ya.make b/contrib/python/ydb/py3/ya.make index 1fe3532c5ff..af4db615f19 100644 --- a/contrib/python/ydb/py3/ya.make +++ b/contrib/python/ydb/py3/ya.make @@ -2,7 +2,7 @@ PY3_LIBRARY() -VERSION(3.26.4) +VERSION(3.26.5) LICENSE(Apache-2.0) diff --git a/contrib/python/ydb/py3/ydb/_errors.py b/contrib/python/ydb/py3/ydb/_errors.py index 3f4263502cf..1e969c09c89 100644 --- a/contrib/python/ydb/py3/ydb/_errors.py +++ b/contrib/python/ydb/py3/ydb/_errors.py @@ -6,6 +6,7 @@ from . import issues _errors_retriable_fast_backoff_types = [ issues.Unavailable, issues.ClientInternalError, + issues.SessionExpired, ] _errors_retriable_slow_backoff_types = [ issues.Aborted, diff --git a/contrib/python/ydb/py3/ydb/ydb_version.py b/contrib/python/ydb/py3/ydb/ydb_version.py index 1b6a705b715..83d85b17414 100644 --- a/contrib/python/ydb/py3/ydb/ydb_version.py +++ b/contrib/python/ydb/py3/ydb/ydb_version.py @@ -1 +1 @@ -VERSION = "3.26.4" +VERSION = "3.26.5" |
