summaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorAlexSm <[email protected]>2024-01-09 18:56:40 +0100
committerGitHub <[email protected]>2024-01-09 18:56:40 +0100
commite95f266d2a3e48e62015220588a4fd73d5d5a5cb (patch)
treea8a784b6931fe52ad5f511cfef85af14e5f63991 /contrib/python/hypothesis
parent50a65e3b48a82d5b51f272664da389f2e0b0c99a (diff)
Library import 6 (#888)
Diffstat (limited to 'contrib/python/hypothesis')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/compat.py45
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py5
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py3
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
6 files changed, 54 insertions, 5 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index c243f745139..b70d38e2c2f 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.92.0
+Version: 6.92.1
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/compat.py b/contrib/python/hypothesis/py3/hypothesis/internal/compat.py
index 3eaed1eba16..41e8ce61d11 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/compat.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/compat.py
@@ -9,6 +9,8 @@
# obtain one at https://mozilla.org/MPL/2.0/.
import codecs
+import copy
+import dataclasses
import inspect
import platform
import sys
@@ -188,3 +190,46 @@ def bad_django_TestCase(runner):
from hypothesis.extra.django._impl import HypothesisTestCase
return not isinstance(runner, HypothesisTestCase)
+
+
+# see issue #3812
+if sys.version_info[:2] < (3, 12):
+
+ def dataclass_asdict(obj, *, dict_factory=dict):
+ """
+ A vendored variant of dataclasses.asdict. Includes the bugfix for
+ defaultdicts (cpython/32056) for all versions. See also issues/3812.
+
+ This should be removed whenever we drop support for 3.11. We can use the
+ standard dataclasses.asdict after that point.
+ """
+ if not dataclasses._is_dataclass_instance(obj): # pragma: no cover
+ raise TypeError("asdict() should be called on dataclass instances")
+ return _asdict_inner(obj, dict_factory)
+
+else: # pragma: no cover
+ dataclass_asdict = dataclasses.asdict
+
+
+def _asdict_inner(obj, dict_factory):
+ if dataclasses._is_dataclass_instance(obj):
+ return dict_factory(
+ (f.name, _asdict_inner(getattr(obj, f.name), dict_factory))
+ for f in dataclasses.fields(obj)
+ )
+ elif isinstance(obj, tuple) and hasattr(obj, "_fields"):
+ return type(obj)(*[_asdict_inner(v, dict_factory) for v in obj])
+ elif isinstance(obj, (list, tuple)):
+ return type(obj)(_asdict_inner(v, dict_factory) for v in obj)
+ elif isinstance(obj, dict):
+ if hasattr(type(obj), "default_factory"):
+ result = type(obj)(obj.default_factory)
+ for k, v in obj.items():
+ result[_asdict_inner(k, dict_factory)] = _asdict_inner(v, dict_factory)
+ return result
+ return type(obj)(
+ (_asdict_inner(k, dict_factory), _asdict_inner(v, dict_factory))
+ for k, v in obj.items()
+ )
+ else:
+ return copy.deepcopy(obj)
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
index a5a862635a5..03653c61e11 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
@@ -77,6 +77,7 @@ from hypothesis.internal.compat import (
from hypothesis.internal.conjecture.utils import calc_label_from_cls, check_sample
from hypothesis.internal.entropy import get_seeder_and_restorer
from hypothesis.internal.floats import float_of
+from hypothesis.internal.observability import TESTCASE_CALLBACKS
from hypothesis.internal.reflection import (
define_function_signature,
get_pretty_function_description,
@@ -2103,7 +2104,9 @@ class DataObject:
self.count += 1
printer = RepresentationPrinter(context=current_build_context())
desc = f"Draw {self.count}{'' if label is None else f' ({label})'}: "
- self.conjecture_data._observability_args[desc] = to_jsonable(result)
+ if TESTCASE_CALLBACKS:
+ self.conjecture_data._observability_args[desc] = to_jsonable(result)
+
printer.text(desc)
printer.pretty(result)
note(printer.getvalue())
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
index 995b179b40c..b2a7661cd6b 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/utils.py
@@ -16,6 +16,7 @@ from typing import TYPE_CHECKING, Callable, Dict
import attr
from hypothesis.internal.cache import LRUReusedCache
+from hypothesis.internal.compat import dataclass_asdict
from hypothesis.internal.floats import float_to_int
from hypothesis.internal.reflection import proxies
from hypothesis.vendor.pretty import pretty
@@ -177,7 +178,7 @@ def to_jsonable(obj: object) -> object:
and dcs.is_dataclass(obj)
and not isinstance(obj, type)
):
- return to_jsonable(dcs.asdict(obj))
+ return to_jsonable(dataclass_asdict(obj))
if attr.has(type(obj)):
return to_jsonable(attr.asdict(obj, recurse=False)) # type: ignore
if (pyd := sys.modules.get("pydantic")) and isinstance(obj, pyd.BaseModel):
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index 83570977044..937332138d1 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, 92, 0)
+__version_info__ = (6, 92, 1)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 456dabd865d..80e21c22c23 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.92.0)
+VERSION(6.92.1)
LICENSE(MPL-2.0)