|
114 | 114 | TextStrategy,
|
115 | 115 | )
|
116 | 116 | from hypothesis.strategies._internal.utils import cacheable, defines_strategy
|
117 |
| -from hypothesis.utils.conventions import infer, not_set |
| 117 | +from hypothesis.utils.conventions import not_set |
118 | 118 |
|
119 | 119 | if sys.version_info >= (3, 10): # pragma: no cover
|
120 |
| - from types import EllipsisType as InferType |
| 120 | + from types import EllipsisType as EllipsisType |
121 | 121 | elif typing.TYPE_CHECKING: # pragma: no cover
|
122 |
| - from builtins import ellipsis as InferType |
| 122 | + from builtins import ellipsis as EllipsisType |
123 | 123 | else:
|
124 |
| - InferType = type(Ellipsis) |
| 124 | + EllipsisType = type(Ellipsis) |
125 | 125 |
|
126 | 126 |
|
127 | 127 | try:
|
@@ -863,7 +863,7 @@ def __repr__(self):
|
863 | 863 | @defines_strategy()
|
864 | 864 | def builds(
|
865 | 865 | *callable_and_args: Union[Callable[..., Ex], SearchStrategy[Any]],
|
866 |
| - **kwargs: Union[SearchStrategy[Any], InferType], |
| 866 | + **kwargs: Union[SearchStrategy[Any], EllipsisType], |
867 | 867 | ) -> SearchStrategy[Ex]:
|
868 | 868 | """Generates values by drawing from ``args`` and ``kwargs`` and passing
|
869 | 869 | them to the callable (provided as the first positional argument) in the
|
@@ -898,14 +898,14 @@ def builds(
|
898 | 898 | "target to construct."
|
899 | 899 | )
|
900 | 900 |
|
901 |
| - if infer in args: # type: ignore # we only annotated the allowed types |
| 901 | + if ... in args: # type: ignore # we only annotated the allowed types |
902 | 902 | # Avoid an implementation nightmare juggling tuples and worse things
|
903 | 903 | raise InvalidArgument(
|
904 | 904 | "... was passed as a positional argument to "
|
905 | 905 | "builds(), but is only allowed as a keyword arg"
|
906 | 906 | )
|
907 | 907 | required = required_args(target, args, kwargs)
|
908 |
| - to_infer = {k for k, v in kwargs.items() if v is infer} |
| 908 | + to_infer = {k for k, v in kwargs.items() if v is ...} |
909 | 909 | if required or to_infer:
|
910 | 910 | if isinstance(target, type) and attr.has(target):
|
911 | 911 | # Use our custom introspection for attrs classes
|
@@ -1993,7 +1993,7 @@ def _functions(*, like, returns, pure):
|
1993 | 1993 | "The first argument to functions() must be a callable to imitate, "
|
1994 | 1994 | f"but got non-callable like={nicerepr(like)!r}"
|
1995 | 1995 | )
|
1996 |
| - if returns is None or returns is infer: |
| 1996 | + if returns in (None, ...): |
1997 | 1997 | # Passing `None` has never been *documented* as working, but it still
|
1998 | 1998 | # did from May 2020 to Jan 2022 so we'll avoid breaking it without cause.
|
1999 | 1999 | hints = get_type_hints(like)
|
@@ -2036,7 +2036,7 @@ def functions(
|
2036 | 2036 | ...
|
2037 | 2037 |
|
2038 | 2038 | @defines_strategy()
|
2039 |
| - def functions(*, like=lambda: None, returns=infer, pure=False): |
| 2039 | + def functions(*, like=lambda: None, returns=..., pure=False): |
2040 | 2040 | # We shouldn't need overloads here, but mypy disallows default args for
|
2041 | 2041 | # generics: https://github.com/python/mypy/issues/3737
|
2042 | 2042 | """functions(*, like=lambda: None, returns=..., pure=False)
|
@@ -2067,7 +2067,7 @@ def functions(*, like=lambda: None, returns=infer, pure=False):
|
2067 | 2067 | def functions(
|
2068 | 2068 | *,
|
2069 | 2069 | like: Callable[..., Any] = lambda: None,
|
2070 |
| - returns: Union[SearchStrategy[Any], InferType] = infer, |
| 2070 | + returns: Union[SearchStrategy[Any], EllipsisType] = ..., |
2071 | 2071 | pure: bool = False,
|
2072 | 2072 | ) -> SearchStrategy[Callable[..., Any]]:
|
2073 | 2073 | """functions(*, like=lambda: None, returns=..., pure=False)
|
|
0 commit comments