aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis/py3
diff options
context:
space:
mode:
authorrobot-piglet <robot-piglet@yandex-team.com>2024-02-19 14:22:33 +0300
committerrobot-piglet <robot-piglet@yandex-team.com>2024-02-19 14:31:45 +0300
commit98c52a915f46d883958e582e7296c7dcd90ee826 (patch)
tree15c69e1e7d40b6a3c5d70c29cfcebe5e5542c3f3 /contrib/python/hypothesis/py3
parentebd081a211ea18652b9871386bc3931466aaeea1 (diff)
downloadydb-98c52a915f46d883958e582e7296c7dcd90ee826.tar.gz
Intermediate changes
Diffstat (limited to 'contrib/python/hypothesis/py3')
-rw-r--r--contrib/python/hypothesis/py3/.dist-info/METADATA6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/control.py37
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/extra/_patching.py24
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/extra/codemods.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/extra/pandas/impl.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py12
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/escalation.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/reflection.py3
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/provisional.py8
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py27
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/vendor/pretty.py2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt4
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
17 files changed, 112 insertions, 61 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index 22fef6f6ba..01f8ae0a0a 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.97.5
+Version: 6.98.0
Summary: A library for property-based testing
Home-page: https://hypothesis.works
Author: David R. MacIver and Zac Hatfield-Dodds
@@ -53,7 +53,7 @@ Requires-Dist: pytz >=2014.1 ; extra == 'all'
Requires-Dist: redis >=3.0.0 ; extra == 'all'
Requires-Dist: rich >=9.0.0 ; extra == 'all'
Requires-Dist: backports.zoneinfo >=0.2.1 ; (python_version < "3.9") and extra == 'all'
-Requires-Dist: tzdata >=2023.4 ; (sys_platform == "win32") and extra == 'all'
+Requires-Dist: tzdata >=2023.4 ; (sys_platform == "win32" or sys_platform == "emscripten") and extra == 'all'
Provides-Extra: cli
Requires-Dist: click >=7.0 ; extra == 'cli'
Requires-Dist: black >=19.10b0 ; extra == 'cli'
@@ -82,7 +82,7 @@ Provides-Extra: redis
Requires-Dist: redis >=3.0.0 ; extra == 'redis'
Provides-Extra: zoneinfo
Requires-Dist: backports.zoneinfo >=0.2.1 ; (python_version < "3.9") and extra == 'zoneinfo'
-Requires-Dist: tzdata >=2023.4 ; (sys_platform == "win32") and extra == 'zoneinfo'
+Requires-Dist: tzdata >=2023.4 ; (sys_platform == "win32" or sys_platform == "emscripten") and extra == 'zoneinfo'
==========
Hypothesis
diff --git a/contrib/python/hypothesis/py3/hypothesis/control.py b/contrib/python/hypothesis/py3/hypothesis/control.py
index f4a400072f..ea085b0b55 100644
--- a/contrib/python/hypothesis/py3/hypothesis/control.py
+++ b/contrib/python/hypothesis/py3/hypothesis/control.py
@@ -10,7 +10,9 @@
import inspect
import math
+import random
from collections import defaultdict
+from contextlib import contextmanager
from typing import Any, NoReturn, Union
from weakref import WeakKeyDictionary
@@ -91,6 +93,38 @@ def current_build_context() -> "BuildContext":
return context
+class RandomSeeder:
+ def __init__(self, seed):
+ self.seed = seed
+
+ def __repr__(self):
+ return f"RandomSeeder({self.seed!r})"
+
+
+class _Checker:
+ def __init__(self) -> None:
+ self.saw_global_random = False
+
+ def __call__(self, x):
+ self.saw_global_random |= isinstance(x, RandomSeeder)
+ return x
+
+
+@contextmanager
+def deprecate_random_in_strategy(fmt, *args):
+ _global_rand_state = random.getstate()
+ yield (checker := _Checker())
+ if _global_rand_state != random.getstate() and not checker.saw_global_random:
+ # raise InvalidDefinition
+ note_deprecation(
+ "Do not use the `random` module inside strategies; instead "
+ "consider `st.randoms()`, `st.sampled_from()`, etc. " + fmt.format(*args),
+ since="2024-02-05",
+ has_codemod=False,
+ stacklevel=1,
+ )
+
+
class BuildContext:
def __init__(self, data, *, is_final=False, close_on_capture=True):
assert isinstance(data, ConjectureData)
@@ -119,7 +153,8 @@ class BuildContext:
kwargs = {}
for k, s in kwarg_strategies.items():
start_idx = self.data.index
- obj = self.data.draw(s, observe_as=f"generate:{k}")
+ with deprecate_random_in_strategy("from {}={!r}", k, s) as check:
+ obj = check(self.data.draw(s, observe_as=f"generate:{k}"))
end_idx = self.data.index
kwargs[k] = obj
diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/_patching.py b/contrib/python/hypothesis/py3/hypothesis/extra/_patching.py
index 49b15ebc37..2660e04a90 100644
--- a/contrib/python/hypothesis/py3/hypothesis/extra/_patching.py
+++ b/contrib/python/hypothesis/py3/hypothesis/extra/_patching.py
@@ -94,16 +94,20 @@ class AddExamplesCodemod(VisitorBasedCodemodCommand):
# If we have black installed, remove trailing comma, _unless_ there's a comment
node = node.with_changes(
func=self.decorator_func,
- args=[
- a.with_changes(
- comma=a.comma
- if m.findall(a.comma, m.Comment())
- else cst.MaybeSentinel.DEFAULT
- )
- for a in node.args
- ]
- if black
- else node.args,
+ args=(
+ [
+ a.with_changes(
+ comma=(
+ a.comma
+ if m.findall(a.comma, m.Comment())
+ else cst.MaybeSentinel.DEFAULT
+ )
+ )
+ for a in node.args
+ ]
+ if black
+ else node.args
+ ),
)
# Note: calling a method on a decorator requires PEP-614, i.e. Python 3.9+,
# but plumbing two cases through doesn't seem worth the trouble :-/
diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/codemods.py b/contrib/python/hypothesis/py3/hypothesis/extra/codemods.py
index b2828c31c3..3de0580ada 100644
--- a/contrib/python/hypothesis/py3/hypothesis/extra/codemods.py
+++ b/contrib/python/hypothesis/py3/hypothesis/extra/codemods.py
@@ -218,9 +218,11 @@ class HypothesisFixPositionalKeywonlyArgs(VisitorBasedCodemodCommand):
whitespace_after=cst.SimpleWhitespace(""),
)
newargs = [
- arg
- if arg.keyword or arg.star or p.kind is not Parameter.KEYWORD_ONLY
- else arg.with_changes(keyword=cst.Name(p.name), equal=assign_nospace)
+ (
+ arg
+ if arg.keyword or arg.star or p.kind is not Parameter.KEYWORD_ONLY
+ else arg.with_changes(keyword=cst.Name(p.name), equal=assign_nospace)
+ )
for p, arg in zip(params, updated_node.args)
]
return updated_node.with_changes(args=newargs)
diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py b/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py
index 68e6a85c29..3404088ed0 100644
--- a/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py
+++ b/contrib/python/hypothesis/py3/hypothesis/extra/ghostwriter.py
@@ -770,9 +770,11 @@ def _write_call(
subtypes of `except_`, which will be handled in an outer try-except block.
"""
args = ", ".join(
- (v or p.name)
- if p.kind is inspect.Parameter.POSITIONAL_ONLY
- else f"{p.name}={v or p.name}"
+ (
+ (v or p.name)
+ if p.kind is inspect.Parameter.POSITIONAL_ONLY
+ else f"{p.name}={v or p.name}"
+ )
for v, p in zip_longest(pass_variables, _get_params(func).values())
)
call = f"{_get_qualname(func, include_module=True)}({args})"
diff --git a/contrib/python/hypothesis/py3/hypothesis/extra/pandas/impl.py b/contrib/python/hypothesis/py3/hypothesis/extra/pandas/impl.py
index 4801b1ad46..7b53a8be42 100644
--- a/contrib/python/hypothesis/py3/hypothesis/extra/pandas/impl.py
+++ b/contrib/python/hypothesis/py3/hypothesis/extra/pandas/impl.py
@@ -346,9 +346,11 @@ def series(
return pandas.Series(
(),
index=index,
- dtype=dtype
- if dtype is not None
- else draw(dtype_for_elements_strategy(elements)),
+ dtype=(
+ dtype
+ if dtype is not None
+ else draw(dtype_for_elements_strategy(elements))
+ ),
name=draw(name),
)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
index 4e43477c5e..bc850254b9 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
@@ -1578,9 +1578,11 @@ class ConjectureData:
examples=self.examples,
blocks=self.blocks,
output=self.output,
- extra_information=self.extra_information
- if self.extra_information.has_information()
- else None,
+ extra_information=(
+ self.extra_information
+ if self.extra_information.has_information()
+ else None
+ ),
has_discards=self.has_discards,
target_observations=self.target_observations,
tags=frozenset(self.tags),
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
index ec12b028b8..0da103a030 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
@@ -110,12 +110,10 @@ class IntList(Sequence[int]):
return len(self.__underlying)
@overload
- def __getitem__(self, i: int) -> int:
- ... # pragma: no cover
+ def __getitem__(self, i: int) -> int: ... # pragma: no cover
@overload
- def __getitem__(self, i: slice) -> "IntList":
- ... # pragma: no cover
+ def __getitem__(self, i: slice) -> "IntList": ... # pragma: no cover
def __getitem__(self, i: Union[int, slice]) -> "Union[int, IntList]":
if isinstance(i, slice):
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
index 39a515d296..b762b89c96 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
@@ -627,16 +627,16 @@ class Shrinker:
# This *can't* be a shrink because none of the components were.
assert shrink_target is self.shrink_target
if result.status == Status.VALID:
- self.shrink_target.slice_comments[
- (0, 0)
- ] = "The test sometimes passed when commented parts were varied together."
+ self.shrink_target.slice_comments[(0, 0)] = (
+ "The test sometimes passed when commented parts were varied together."
+ )
break # Test passed, this param can't vary freely.
elif self.__predicate(result): # pragma: no branch
n_same_failures_together += 1
if n_same_failures_together >= 100:
- self.shrink_target.slice_comments[
- (0, 0)
- ] = "The test always failed when commented parts were varied together."
+ self.shrink_target.slice_comments[(0, 0)] = (
+ "The test always failed when commented parts were varied together."
+ )
break
def greedy_shrink(self):
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/escalation.py b/contrib/python/hypothesis/py3/hypothesis/internal/escalation.py
index 9261d2aefc..c3c678d239 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/escalation.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/escalation.py
@@ -142,9 +142,11 @@ class InterestingOrigin(NamedTuple):
# to support introspection when debugging, so we can use that unconditionally.
cls.from_exception(exception.__context__) if exception.__context__ else (),
# We distinguish exception groups by the inner exceptions, as for __context__
- tuple(map(cls.from_exception, exception.exceptions))
- if isinstance(exception, BaseExceptionGroup)
- else (),
+ (
+ tuple(map(cls.from_exception, exception.exceptions))
+ if isinstance(exception, BaseExceptionGroup)
+ else ()
+ ),
)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
index e62ab28f36..a829f097be 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/reflection.py
@@ -23,6 +23,7 @@ import warnings
from functools import partial, wraps
from io import StringIO
from keyword import iskeyword
+from random import _inst as global_random_instance
from tokenize import COMMENT, detect_encoding, generate_tokens, untokenize
from types import ModuleType
from typing import TYPE_CHECKING, Any, Callable
@@ -446,6 +447,8 @@ def get_pretty_function_description(f):
# Some objects, like `builtins.abs` are of BuiltinMethodType but have
# their module as __self__. This might include c-extensions generally?
if not (self is None or inspect.isclass(self) or inspect.ismodule(self)):
+ if self is global_random_instance:
+ return f"random.{name}"
return f"{self!r}.{name}"
elif isinstance(name, str) and getattr(dict, name, object()) is f:
# special case for keys/values views in from_type() / ghostwriter output
diff --git a/contrib/python/hypothesis/py3/hypothesis/provisional.py b/contrib/python/hypothesis/py3/hypothesis/provisional.py
index dec1abfc61..a6f1c4afc5 100644
--- a/contrib/python/hypothesis/py3/hypothesis/provisional.py
+++ b/contrib/python/hypothesis/py3/hypothesis/provisional.py
@@ -146,9 +146,11 @@ def domains(
_url_fragments_strategy = (
st.lists(
st.builds(
- lambda char, encode: f"%{ord(char):02X}"
- if (encode or char not in FRAGMENT_SAFE_CHARACTERS)
- else char,
+ lambda char, encode: (
+ f"%{ord(char):02X}"
+ if (encode or char not in FRAGMENT_SAFE_CHARACTERS)
+ else char
+ ),
st.characters(min_codepoint=0, max_codepoint=255),
st.booleans(),
),
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
index 234b8de822..8ab02d0b39 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
@@ -53,7 +53,13 @@ from uuid import UUID
import attr
from hypothesis._settings import note_deprecation
-from hypothesis.control import cleanup, current_build_context, note
+from hypothesis.control import (
+ RandomSeeder,
+ cleanup,
+ current_build_context,
+ deprecate_random_in_strategy,
+ note,
+)
from hypothesis.errors import (
HypothesisSideeffectWarning,
HypothesisWarning,
@@ -998,14 +1004,6 @@ def randoms(
)
-class RandomSeeder:
- def __init__(self, seed):
- self.seed = seed
-
- def __repr__(self):
- return f"RandomSeeder({self.seed!r})"
-
-
class RandomModule(SearchStrategy):
def do_draw(self, data):
# It would be unsafe to do run this method more than once per test case,
@@ -1835,9 +1833,11 @@ def _composite(f):
params = params[1:]
newsig = sig.replace(
parameters=params,
- return_annotation=SearchStrategy
- if sig.return_annotation is sig.empty
- else SearchStrategy[sig.return_annotation],
+ return_annotation=(
+ SearchStrategy
+ if sig.return_annotation is sig.empty
+ else SearchStrategy[sig.return_annotation]
+ ),
)
@defines_strategy()
@@ -2134,7 +2134,8 @@ class DataObject:
self.count += 1
printer = RepresentationPrinter(context=current_build_context())
desc = f"Draw {self.count}{'' if label is None else f' ({label})'}: "
- result = self.conjecture_data.draw(strategy, observe_as=f"generate:{desc}")
+ with deprecate_random_in_strategy("{}from {!r}", desc, strategy):
+ result = self.conjecture_data.draw(strategy, observe_as=f"generate:{desc}")
if TESTCASE_CALLBACKS:
self.conjecture_data._observability_args[desc] = to_jsonable(result)
diff --git a/contrib/python/hypothesis/py3/hypothesis/vendor/pretty.py b/contrib/python/hypothesis/py3/hypothesis/vendor/pretty.py
index 056f1795d3..35451b9961 100644
--- a/contrib/python/hypothesis/py3/hypothesis/vendor/pretty.py
+++ b/contrib/python/hypothesis/py3/hypothesis/vendor/pretty.py
@@ -764,7 +764,7 @@ def for_type_by_name(type_module, type_name, func):
"""Add a pretty printer for a type specified by the module and name of a
type rather than the type object itself."""
key = (type_module, type_name)
- oldfunc = _deferred_type_pprinters.get(key, None)
+ oldfunc = _deferred_type_pprinters.get(key)
_deferred_type_pprinters[key] = func
return oldfunc
diff --git a/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt b/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
index 589b768abd..c520fc063e 100644
--- a/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
+++ b/contrib/python/hypothesis/py3/hypothesis/vendor/tlds-alpha-by-domain.txt
@@ -1,4 +1,4 @@
-# Version 2023122300, Last Updated Sat Dec 23 07:07:01 2023 UTC
+# Version 2024020300, Last Updated Sat Feb 3 07:07:01 2024 UTC
AAA
AARP
ABB
@@ -96,7 +96,6 @@ BA
BABY
BAIDU
BANAMEX
-BANANAREPUBLIC
BAND
BANK
BAR
@@ -855,7 +854,6 @@ OFFICE
OKINAWA
OLAYAN
OLAYANGROUP
-OLDNAVY
OLLO
OM
OMEGA
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index 307de471d0..3d7dd6774b 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, 97, 5)
+__version_info__ = (6, 98, 0)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 1914b61e35..5b197c3343 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.97.5)
+VERSION(6.98.0)
LICENSE(MPL-2.0)