From 8e76016def2cb790c16e91ff41c33dae3951d0a0 Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Thu, 6 Feb 2025 18:15:27 -0500 Subject: [PATCH] more typing --- hypothesis-python/src/hypothesis/core.py | 9 ++++++++- hypothesis-python/src/hypothesis/internal/reflection.py | 6 ++++-- hypothesis-python/tests/conjecture/test_optimiser.py | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/hypothesis-python/src/hypothesis/core.py b/hypothesis-python/src/hypothesis/core.py index aacf020c72..47711f7c44 100644 --- a/hypothesis-python/src/hypothesis/core.py +++ b/hypothesis-python/src/hypothesis/core.py @@ -25,6 +25,7 @@ from collections import defaultdict from collections.abc import Coroutine, Generator, Hashable, Iterable, Sequence from functools import partial +from inspect import Parameter from random import Random from typing import ( TYPE_CHECKING, @@ -633,7 +634,13 @@ class Stuff: given_kwargs: dict = attr.ib(factory=dict) -def process_arguments_to_given(wrapped_test, arguments, kwargs, given_kwargs, params): +def process_arguments_to_given( + wrapped_test: Any, + arguments: Sequence[object], + kwargs: dict[str, object], + given_kwargs: dict[str, SearchStrategy], + params: dict[str, Parameter], +) -> tuple[Sequence[object], dict[str, object], Stuff]: selfy = None arguments, kwargs = convert_positional_arguments(wrapped_test, arguments, kwargs) diff --git a/hypothesis-python/src/hypothesis/internal/reflection.py b/hypothesis-python/src/hypothesis/internal/reflection.py index c735c9a663..dffc5ab587 100644 --- a/hypothesis-python/src/hypothesis/internal/reflection.py +++ b/hypothesis-python/src/hypothesis/internal/reflection.py @@ -21,7 +21,7 @@ import textwrap import types import warnings -from collections.abc import MutableMapping +from collections.abc import MutableMapping, Sequence from functools import partial, wraps from io import StringIO from keyword import iskeyword @@ -214,7 +214,9 @@ def convert_keyword_arguments(function, args, kwargs): return bound.args, bound.kwargs -def convert_positional_arguments(function, args, kwargs): +def convert_positional_arguments( + function: Any, args: Sequence[object], kwargs: dict[str, object] +) -> tuple[tuple[object, ...], dict[str, object]]: """Return a tuple (new_args, new_kwargs) where all possible arguments have been moved to kwargs. diff --git a/hypothesis-python/tests/conjecture/test_optimiser.py b/hypothesis-python/tests/conjecture/test_optimiser.py index 7278bfcb43..aa6e6c37bf 100644 --- a/hypothesis-python/tests/conjecture/test_optimiser.py +++ b/hypothesis-python/tests/conjecture/test_optimiser.py @@ -13,8 +13,8 @@ import pytest from hypothesis import assume, example, given, settings -from hypothesis.internal.conjecture.data import Status from hypothesis.internal.conjecture.choice import ChoiceNode +from hypothesis.internal.conjecture.data import Status from hypothesis.internal.conjecture.datatree import compute_max_children from hypothesis.internal.conjecture.engine import ConjectureRunner, RunIsComplete from hypothesis.internal.entropy import deterministic_PRNG