From 00be614833eb39159cfe8dde565589a9342a2412 Mon Sep 17 00:00:00 2001 From: Khabib <136262760+Khabib73@users.noreply.github.com> Date: Tue, 6 Oct 2026 11:57:21 +0300 Subject: [PATCH 1/2] pre-commit autoupdate --- .pre-commit-config.yaml | 4 ++-- returns/contrib/hypothesis/laws.py | 4 ++-- returns/contrib/hypothesis/type_resolver.py | 4 ++-- returns/contrib/pytest/plugin.py | 16 ++++++++++++---- returns/primitives/tracing.py | 4 ++-- 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index f39f04944..7ac2cc657 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -19,7 +19,7 @@ repos: hooks: - id: shellcheck - repo: https://github.com/astral-sh/ruff-pre-commit - rev: a56c0b927e6465d37cae3e97d35d4d18ab2b96cd # frozen: v0.16.9 + rev: f12be1ebaa5351c1fc76472de98db2c3446c8253 # frozen: v0.16.10 hooks: - id: ruff args: ["--exit-non-zero-on-fix"] @@ -32,7 +32,7 @@ repos: files: ^docs/ - repo: https://github.com/crate-ci/typos - rev: 4141ff14cb566df76c473c786332c186a4fd71d1 # frozen: v1.50.3 + rev: dd369349b73c245acd4dd4154a4bdf771d052150 # frozen: typos-dict-v0.14.2 hooks: - id: typos - repo: https://github.com/codespell-project/codespell diff --git a/returns/contrib/hypothesis/laws.py b/returns/contrib/hypothesis/laws.py index 611fe4002..74945dbdc 100644 --- a/returns/contrib/hypothesis/laws.py +++ b/returns/contrib/hypothesis/laws.py @@ -1,6 +1,6 @@ import dataclasses import inspect -from collections.abc import Callable, Iterator +from collections.abc import Callable, Generator from contextlib import ExitStack, contextmanager from typing import Any, Self, TypeVar, final, overload @@ -198,7 +198,7 @@ def type_vars_factory(thing: type[object]) -> StrategyFactory: @contextmanager -def clean_plugin_context() -> Iterator[None]: +def clean_plugin_context() -> Generator[None, None, None]: """ We register a lot of types in `_entrypoint.py`, we need to clean them. diff --git a/returns/contrib/hypothesis/type_resolver.py b/returns/contrib/hypothesis/type_resolver.py index 0a574a4cd..ae59bcea6 100644 --- a/returns/contrib/hypothesis/type_resolver.py +++ b/returns/contrib/hypothesis/type_resolver.py @@ -1,6 +1,6 @@ """Make `hypothesis` resolve types to the right strategies.""" -from collections.abc import Callable, Iterator, Mapping +from collections.abc import Callable, Generator, Mapping from contextlib import contextmanager from typing import TypeAlias, TypeVar @@ -18,7 +18,7 @@ @contextmanager def strategies_for_types( mapping: Mapping[type[object], StrategyFactory], -) -> Iterator[None]: +) -> Generator[None, None, None]: """ Temporarily register strategies with `hypothesis`. diff --git a/returns/contrib/pytest/plugin.py b/returns/contrib/pytest/plugin.py index b08a16aea..8838b63bf 100644 --- a/returns/contrib/pytest/plugin.py +++ b/returns/contrib/pytest/plugin.py @@ -1,10 +1,18 @@ import inspect import sys -from collections.abc import Callable, Iterator +from collections.abc import Callable, Generator, Iterator from contextlib import ExitStack, contextmanager from functools import partial, wraps from types import FrameType, MappingProxyType -from typing import TYPE_CHECKING, Any, Final, TypeAlias, TypeVar, Union, final +from typing import ( + TYPE_CHECKING, + Any, + Final, + TypeAlias, + TypeVar, + Union, + final, +) from unittest import mock import pytest @@ -62,7 +70,7 @@ def is_error_handled(self, container) -> bool: def assert_trace( # noqa: WPS602 trace_type: _ReturnsResultType, function_to_search: _FunctionType, - ) -> Iterator[None]: + ) -> Generator[None, None, None]: """ Ensures that a given function was called during execution. @@ -135,7 +143,7 @@ def returns() -> Iterator[ReturnsAsserts]: @contextmanager -def _spy_error_handling() -> Iterator[_ErrorsHandled]: +def _spy_error_handling() -> Generator[_ErrorsHandled, None, None]: """Track error handling of containers.""" errs: _ErrorsHandled = {} with ExitStack() as cleanup: diff --git a/returns/primitives/tracing.py b/returns/primitives/tracing.py index 4354e7d17..baa85731f 100644 --- a/returns/primitives/tracing.py +++ b/returns/primitives/tracing.py @@ -1,5 +1,5 @@ import types -from collections.abc import Callable, Iterator +from collections.abc import Callable, Generator from contextlib import AbstractContextManager, contextmanager from inspect import FrameInfo, stack from typing import TypeVar, overload @@ -59,7 +59,7 @@ def collect_traces( """ @contextmanager - def factory() -> Iterator[None]: + def factory() -> Generator[None, None, None]: unpatched_get_trace = getattr(Failure, '_get_trace') # noqa: B009 substitute_get_trace = types.MethodType(_get_trace, Failure) setattr(Failure, '_get_trace', substitute_get_trace) # noqa: B010 From 7247ff63d07ced1014cdf884c79c6cbc3519cf34 Mon Sep 17 00:00:00 2001 From: Khabib <136262760+Khabib73@users.noreply.github.com> Date: Tue, 6 Oct 2026 18:31:08 +0300 Subject: [PATCH 2/2] Fix annotations --- returns/contrib/hypothesis/laws.py | 2 +- returns/contrib/hypothesis/type_resolver.py | 2 +- returns/contrib/pytest/plugin.py | 4 ++-- returns/primitives/tracing.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/returns/contrib/hypothesis/laws.py b/returns/contrib/hypothesis/laws.py index 74945dbdc..b8a74e8b9 100644 --- a/returns/contrib/hypothesis/laws.py +++ b/returns/contrib/hypothesis/laws.py @@ -198,7 +198,7 @@ def type_vars_factory(thing: type[object]) -> StrategyFactory: @contextmanager -def clean_plugin_context() -> Generator[None, None, None]: +def clean_plugin_context() -> Generator[None]: """ We register a lot of types in `_entrypoint.py`, we need to clean them. diff --git a/returns/contrib/hypothesis/type_resolver.py b/returns/contrib/hypothesis/type_resolver.py index ae59bcea6..363d15a7e 100644 --- a/returns/contrib/hypothesis/type_resolver.py +++ b/returns/contrib/hypothesis/type_resolver.py @@ -18,7 +18,7 @@ @contextmanager def strategies_for_types( mapping: Mapping[type[object], StrategyFactory], -) -> Generator[None, None, None]: +) -> Generator[None]: """ Temporarily register strategies with `hypothesis`. diff --git a/returns/contrib/pytest/plugin.py b/returns/contrib/pytest/plugin.py index 8838b63bf..f7c4fb9fb 100644 --- a/returns/contrib/pytest/plugin.py +++ b/returns/contrib/pytest/plugin.py @@ -70,7 +70,7 @@ def is_error_handled(self, container) -> bool: def assert_trace( # noqa: WPS602 trace_type: _ReturnsResultType, function_to_search: _FunctionType, - ) -> Generator[None, None, None]: + ) -> Generator[None]: """ Ensures that a given function was called during execution. @@ -143,7 +143,7 @@ def returns() -> Iterator[ReturnsAsserts]: @contextmanager -def _spy_error_handling() -> Generator[_ErrorsHandled, None, None]: +def _spy_error_handling() -> Generator[_ErrorsHandled]: """Track error handling of containers.""" errs: _ErrorsHandled = {} with ExitStack() as cleanup: diff --git a/returns/primitives/tracing.py b/returns/primitives/tracing.py index baa85731f..b0a130c47 100644 --- a/returns/primitives/tracing.py +++ b/returns/primitives/tracing.py @@ -59,7 +59,7 @@ def collect_traces( """ @contextmanager - def factory() -> Generator[None, None, None]: + def factory() -> Generator[None]: unpatched_get_trace = getattr(Failure, '_get_trace') # noqa: B009 substitute_get_trace = types.MethodType(_get_trace, Failure) setattr(Failure, '_get_trace', substitute_get_trace) # noqa: B010