summaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis/py3
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2024-08-25 12:54:32 +0300
committerrobot-piglet <[email protected]>2024-08-25 13:03:33 +0300
commit4a64a813e1d34e732f35d8a65147974f76395a6f (patch)
treea8da0dede5213f85e45b95047cfbdcf5427cf0b7 /contrib/python/hypothesis/py3
parente9bbee265681b79a9ef9795bdc84cf6996f9cfec (diff)
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis/py3')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA10
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py44
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
4 files changed, 39 insertions, 19 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 1e09939db8f..8b3d585d4b5 100644
--- a/contrib/python/hypothesis/py3/.dist-info/METADATA
+++ b/contrib/python/hypothesis/py3/.dist-info/METADATA
@@ -1,6 +1,6 @@
Metadata-Version: 2.1
Name: hypothesis
-Version: 6.110.1
+Version: 6.110.2
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
@@ -41,10 +41,10 @@ Requires-Dist: exceptiongroup>=1.0.0; python_version < "3.11"
Provides-Extra: all
Requires-Dist: black>=19.10b0; extra == "all"
Requires-Dist: click>=7.0; extra == "all"
-Requires-Dist: crosshair-tool>=0.0.65; extra == "all"
+Requires-Dist: crosshair-tool>=0.0.66; extra == "all"
Requires-Dist: django>=3.2; extra == "all"
Requires-Dist: dpcontracts>=0.4; extra == "all"
-Requires-Dist: hypothesis-crosshair>=0.0.11; extra == "all"
+Requires-Dist: hypothesis-crosshair>=0.0.12; extra == "all"
Requires-Dist: lark>=0.10.1; extra == "all"
Requires-Dist: libcst>=0.3.16; extra == "all"
Requires-Dist: numpy>=1.17.3; extra == "all"
@@ -63,8 +63,8 @@ Requires-Dist: rich>=9.0.0; extra == "cli"
Provides-Extra: codemods
Requires-Dist: libcst>=0.3.16; extra == "codemods"
Provides-Extra: crosshair
-Requires-Dist: hypothesis-crosshair>=0.0.11; extra == "crosshair"
-Requires-Dist: crosshair-tool>=0.0.65; extra == "crosshair"
+Requires-Dist: hypothesis-crosshair>=0.0.12; extra == "crosshair"
+Requires-Dist: crosshair-tool>=0.0.66; extra == "crosshair"
Provides-Extra: dateutil
Requires-Dist: python-dateutil>=1.4; extra == "dateutil"
Provides-Extra: django
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
index 85051cfdbe6..13e01b0b056 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
@@ -194,6 +194,12 @@ except AttributeError: # pragma: no cover
extended_get_origin = get_origin # type: ignore
+# Used on `TypeVar` objects with no default:
+NoDefaults = (
+ getattr(typing, "NoDefault", object()),
+ getattr(typing_extensions, "NoDefault", object()),
+)
+
# We use this variable to be sure that we are working with a type from `typing`:
typing_root_type = (typing._Final, typing._GenericAlias) # type: ignore
@@ -440,9 +446,9 @@ __EVAL_TYPE_TAKES_TYPE_PARAMS = (
)
-def _try_import_forward_ref(thing, bound, *, type_params): # pragma: no cover
+def _try_import_forward_ref(thing, typ, *, type_params): # pragma: no cover
"""
- Tries to import a real bound type from ``TypeVar`` bound to a ``ForwardRef``.
+ Tries to import a real bound or default type from ``ForwardRef`` in ``TypeVar``.
This function is very "magical" to say the least, please don't use it.
This function fully covered, but is excluded from coverage
@@ -452,13 +458,13 @@ def _try_import_forward_ref(thing, bound, *, type_params): # pragma: no cover
kw = {"globalns": vars(sys.modules[thing.__module__]), "localns": None}
if __EVAL_TYPE_TAKES_TYPE_PARAMS:
kw["type_params"] = type_params
- return typing._eval_type(bound, **kw)
+ return typing._eval_type(typ, **kw)
except (KeyError, AttributeError, NameError):
# We fallback to `ForwardRef` instance, you can register it as a type as well:
# >>> from typing import ForwardRef
# >>> from hypothesis import strategies as st
# >>> st.register_type_strategy(ForwardRef('YourType'), your_strategy)
- return bound
+ return typ
def from_typing_type(thing):
@@ -1082,25 +1088,39 @@ def resolve_Callable(thing):
@register(typing.TypeVar)
+@register("TypeVar", module=typing_extensions)
def resolve_TypeVar(thing):
type_var_key = f"typevar={thing!r}"
- if getattr(thing, "__bound__", None) is not None:
- bound = thing.__bound__
- if isinstance(bound, typing.ForwardRef):
+ bound = getattr(thing, "__bound__", None)
+ default = getattr(thing, "__default__", NoDefaults[0])
+ original_strategies = []
+
+ def resolve_strategies(typ):
+ if isinstance(typ, typing.ForwardRef):
# TODO: on Python 3.13 and later, we should work out what type_params
# could be part of this type, and pass them in here.
- bound = _try_import_forward_ref(thing, bound, type_params=())
- strat = unwrap_strategies(st.from_type(bound))
+ typ = _try_import_forward_ref(thing, typ, type_params=())
+ strat = unwrap_strategies(st.from_type(typ))
if not isinstance(strat, OneOfStrategy):
- return strat
- # The bound was a union, or we resolved it as a union of subtypes,
+ original_strategies.append(strat)
+ else:
+ original_strategies.extend(strat.original_strategies)
+
+ if bound is not None:
+ resolve_strategies(bound)
+ if default not in NoDefaults: # pragma: no cover
+ # Coverage requires 3.13 or `typing_extensions` package.
+ resolve_strategies(default)
+
+ if original_strategies:
+ # The bound / default was a union, or we resolved it as a union of subtypes,
# so we need to unpack the strategy to ensure consistency across uses.
# This incantation runs a sampled_from over the strategies inferred for
# each part of the union, wraps that in shared so that we only generate
# from one type per testcase, and flatmaps that back to instances.
return st.shared(
- st.sampled_from(strat.original_strategies), key=type_var_key
+ st.sampled_from(original_strategies), key=type_var_key
).flatmap(lambda s: s)
builtin_scalar_types = [type(None), bool, int, float, str, bytes]
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index e02ca3db876..0c7cb254d54 100644
--- a/contrib/python/hypothesis/py3/hypothesis/version.py
+++ b/contrib/python/hypothesis/py3/hypothesis/version.py
@@ -8,5 +8,5 @@
# v. 2.0. If a copy of the MPL was not distributed with this file, You can
# obtain one at https://mozilla.org/MPL/2.0/.
-__version_info__ = (6, 110, 1)
+__version_info__ = (6, 110, 2)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 44835a36ca2..8113ee865a4 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.110.1)
+VERSION(6.110.2)
LICENSE(MPL-2.0)