Skip to content

Commit

Permalink
Fix CI partially
Browse files Browse the repository at this point in the history
  • Loading branch information
sobolevn committed Dec 1, 2024
1 parent 3269cd8 commit 60994d2
Showing 1 changed file with 4 additions and 14 deletions.
18 changes: 4 additions & 14 deletions returns/contrib/hypothesis/laws.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,24 +157,14 @@ def factory(thing) -> st.SearchStrategy:
pure=True,
)

callable_type = _get_callable_type()
used = types._global_type_lookup[callable_type]
st.register_type_strategy(callable_type, factory)
used = types._global_type_lookup[Callable]
st.register_type_strategy(Callable, factory)

try:
yield
finally:
types._global_type_lookup.pop(callable_type)
st.register_type_strategy(callable_type, used)


def _get_callable_type() -> Any:
# Helper to accommodate changes in `[email protected]`
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')
types._global_type_lookup.pop(Callable)
st.register_type_strategy(Callable, used)


@contextmanager
Expand Down

0 comments on commit 60994d2

Please sign in to comment.