-
-
Notifications
You must be signed in to change notification settings - Fork 119
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
4 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
|