From 6e26ec9622fc3f70cc0cb17234dcf5a157098cb9 Mon Sep 17 00:00:00 2001 From: Maximiliano Curia Date: Sat, 9 Nov 2024 16:26:18 +0100 Subject: [PATCH] fix (laws/pure): compatibility with hypothesis > 6.113.0 Hypothesis is now setting two entries for the Callables strategies, and then it prefers the one using the type origin. While returns lookup for the first set and replaces the strategy, starting with the one without the type origin. This only changes the callable strategy search order to match hypothesis, alternatively we could set both. --- returns/contrib/hypothesis/laws.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/returns/contrib/hypothesis/laws.py b/returns/contrib/hypothesis/laws.py index 2cc672635..07bfa5e01 100644 --- a/returns/contrib/hypothesis/laws.py +++ b/returns/contrib/hypothesis/laws.py @@ -179,10 +179,10 @@ def factory(thing) -> st.SearchStrategy: def _get_callable_type() -> Any: # Helper to accommodate changes in `hypothesis@6.79.0` - if Callable in types._global_type_lookup: # type: ignore - return Callable - elif Callable.__origin__ in types._global_type_lookup: # type: ignore + if Callable.__origin__ in types._global_type_lookup: # type: ignore return Callable.__origin__ # type: ignore + elif Callable in types._global_type_lookup: # type: ignore + return Callable raise RuntimeError('Failed to find Callable type strategy')