Skip to content

Commit 8bcb914

Browse files
authored
Merge pull request HypothesisWorks#3179 from HypothesisWorks/proxies
2 parents d79427b + 0f5768c commit 8bcb914

File tree

3 files changed

+13
-5
lines changed

3 files changed

+13
-5
lines changed

hypothesis-python/RELEASE.rst

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
RELEASE_TYPE: patch
2+
3+
This patch improves annotations on some of Hypothesis' internal functions, in order to
4+
deobfuscate the signatures of some strategies. In particular, strategies shared between
5+
:ref:`hypothesis.extra.numpy <hypothesis-numpy>` and
6+
:ref:`the hypothesis.extra.array_api extra <array-api>` will benefit from this patch.

hypothesis-python/src/hypothesis/internal/reflection.py

+6-4
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,14 @@
2626
from functools import wraps
2727
from tokenize import detect_encoding
2828
from types import ModuleType
29-
from typing import Callable, TypeVar
29+
from typing import TYPE_CHECKING, Callable
3030

3131
from hypothesis.internal.compat import is_typed_named_tuple, update_code_location
3232
from hypothesis.vendor.pretty import pretty
3333

34-
C = TypeVar("C", bound=Callable)
34+
if TYPE_CHECKING:
35+
from hypothesis.strategies._internal.strategies import T
36+
3537
READTHEDOCS = os.environ.get("READTHEDOCS", None) == "True"
3638

3739

@@ -570,9 +572,9 @@ def accept(f):
570572
return accept
571573

572574

573-
def proxies(target):
575+
def proxies(target: "T") -> Callable[[Callable], "T"]:
574576
replace_sig = define_function_signature(
575-
target.__name__.replace("<lambda>", "_lambda_"),
577+
target.__name__.replace("<lambda>", "_lambda_"), # type: ignore
576578
target.__doc__,
577579
getfullargspec_except_self(target),
578580
)

hypothesis-python/src/hypothesis/strategies/_internal/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def cached_strategy(*args, **kwargs):
8585
cache[cache_key] = result
8686
return result
8787

88-
cached_strategy.__clear_cache = clear_cache
88+
cached_strategy.__clear_cache = clear_cache # type: ignore
8989
return cached_strategy
9090

9191

0 commit comments

Comments
 (0)