summaryrefslogtreecommitdiffstats
path: root/contrib/python/hypothesis
diff options
context:
space:
mode:
authorrobot-piglet <[email protected]>2024-08-22 10:43:37 +0300
committerrobot-piglet <[email protected]>2024-08-22 10:52:34 +0300
commit1fbd27b4e37aecbce5bc29b1084ebc08d49c44ab (patch)
treedc2e6502cd69163a7309a5a2b5ee7bc0f7b1d736 /contrib/python/hypothesis
parent09b7cd61fa6d98c03d6612f2130641e209f61a06 (diff)
Intermediate changes
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/cathetus.py2
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py18
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/optimiser.py39
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py40
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py6
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/internal/floats.py66
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py73
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/numbers.py16
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py45
-rw-r--r--contrib/python/hypothesis/py3/hypothesis/version.py2
-rw-r--r--contrib/python/hypothesis/py3/ya.make2
13 files changed, 228 insertions, 89 deletions
diff --git a/contrib/python/hypothesis/py3/.dist-info/METADATA b/contrib/python/hypothesis/py3/.dist-info/METADATA
index e48da7dc0b5..9a38b4132f4 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.108.10
+Version: 6.110.0
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/cathetus.py b/contrib/python/hypothesis/py3/hypothesis/internal/cathetus.py
index 30e0d214f1c..1f8f2fe82b2 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/cathetus.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/cathetus.py
@@ -27,7 +27,7 @@ def cathetus(h, a):
may be inaccurate up to a relative error of (around) floating-point
epsilon.
- Based on the C99 implementation https://github.com/jjgreen/cathetus
+ Based on the C99 implementation https://gitlab.com/jjg/cathetus
"""
if isnan(h):
return nan
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
index 72bc4ba980b..40aad2e8501 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/data.py
@@ -679,6 +679,12 @@ class Examples:
i += n
return Example(self, i)
+ # not strictly necessary as we have len/getitem, but required for mypy.
+ # https://github.com/python/mypy/issues/9737
+ def __iter__(self) -> Iterator[Example]:
+ for i in range(len(self)):
+ yield self[i]
+
@dataclass_transform()
@attr.s(slots=True, frozen=True)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
index 4465f59e5c4..39382637db5 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/junkdrawer.py
@@ -19,12 +19,14 @@ import time
import warnings
from random import Random
from typing import (
+ Any,
Callable,
Dict,
Generic,
Iterable,
Iterator,
List,
+ Literal,
Optional,
Sequence,
Tuple,
@@ -109,10 +111,10 @@ class IntList(Sequence[int]):
def count(self, value: int) -> int:
return self.__underlying.count(value)
- def __repr__(self):
+ def __repr__(self) -> str:
return f"IntList({list(self.__underlying)!r})"
- def __len__(self):
+ def __len__(self) -> int:
return len(self.__underlying)
@overload
@@ -305,7 +307,7 @@ class ensure_free_stackframes:
a reasonable value of N).
"""
- def __enter__(self):
+ def __enter__(self) -> None:
cur_depth = stack_depth_of_caller()
self.old_maxdepth = sys.getrecursionlimit()
# The default CPython recursionlimit is 1000, but pytest seems to bump
@@ -418,8 +420,8 @@ class SelfOrganisingList(Generic[T]):
_gc_initialized = False
-_gc_start = 0
-_gc_cumulative_time = 0
+_gc_start: float = 0
+_gc_cumulative_time: float = 0
# Since gc_callback potentially runs in test context, and perf_counter
# might be monkeypatched, we store a reference to the real one.
@@ -431,7 +433,9 @@ def gc_cumulative_time() -> float:
if not _gc_initialized:
if hasattr(gc, "callbacks"):
# CPython
- def gc_callback(phase, info):
+ def gc_callback(
+ phase: Literal["start", "stop"], info: Dict[str, int]
+ ) -> None:
global _gc_start, _gc_cumulative_time
try:
now = _perf_counter()
@@ -453,7 +457,7 @@ def gc_cumulative_time() -> float:
gc.callbacks.insert(0, gc_callback)
elif hasattr(gc, "hooks"): # pragma: no cover # pypy only
# PyPy
- def hook(stats):
+ def hook(stats: Any) -> None:
global _gc_cumulative_time
try:
_gc_cumulative_time += stats.duration
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/optimiser.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/optimiser.py
index 2f8f7612234..a8f4478453e 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/optimiser.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/optimiser.py
@@ -8,9 +8,11 @@
# 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/.
+from typing import Union
+
from hypothesis.internal.compat import int_from_bytes, int_to_bytes
-from hypothesis.internal.conjecture.data import Status
-from hypothesis.internal.conjecture.engine import BUFFER_SIZE
+from hypothesis.internal.conjecture.data import ConjectureResult, Status, _Overrun
+from hypothesis.internal.conjecture.engine import BUFFER_SIZE, ConjectureRunner
from hypothesis.internal.conjecture.junkdrawer import find_integer
from hypothesis.internal.conjecture.pareto import NO_SCORE
@@ -31,7 +33,13 @@ class Optimiser:
Software Testing and Analysis. ACM, 2017.
"""
- def __init__(self, engine, data, target, max_improvements=100):
+ def __init__(
+ self,
+ engine: ConjectureRunner,
+ data: ConjectureResult,
+ target: str,
+ max_improvements: int = 100,
+ ) -> None:
"""Optimise ``target`` starting from ``data``. Will stop either when
we seem to have found a local maximum or when the target score has
been improved ``max_improvements`` times. This limit is in place to
@@ -42,21 +50,22 @@ class Optimiser:
self.max_improvements = max_improvements
self.improvements = 0
- def run(self):
+ def run(self) -> None:
self.hill_climb()
- def score_function(self, data):
+ def score_function(self, data: ConjectureResult) -> float:
return data.target_observations.get(self.target, NO_SCORE)
@property
- def current_score(self):
+ def current_score(self) -> float:
return self.score_function(self.current_data)
- def consider_new_test_data(self, data):
+ def consider_new_data(self, data: Union[ConjectureResult, _Overrun]) -> bool:
"""Consider a new data object as a candidate target. If it is better
than the current one, return True."""
if data.status < Status.VALID:
return False
+ assert isinstance(data, ConjectureResult)
score = self.score_function(data)
if score < self.current_score:
return False
@@ -73,7 +82,7 @@ class Optimiser:
return True
return False
- def hill_climb(self):
+ def hill_climb(self) -> None:
"""The main hill climbing loop where we actually do the work: Take
data, and attempt to improve its score for target. select_example takes
a data object and returns an index to an example where we should focus
@@ -104,7 +113,7 @@ class Optimiser:
if existing_as_int == max_int_value:
continue
- def attempt_replace(v):
+ def attempt_replace(v: int) -> bool:
"""Try replacing the current block in the current best test case
with an integer of value i. Note that we use the *current*
best and not the one we started with. This helps ensure that
@@ -126,12 +135,14 @@ class Optimiser:
+ bytes(BUFFER_SIZE),
)
- if self.consider_new_test_data(attempt):
+ if self.consider_new_data(attempt):
return True
- if attempt.status < Status.INVALID or len(attempt.buffer) == len(
- self.current_data.buffer
- ):
+ if attempt.status == Status.OVERRUN:
+ return False
+
+ assert isinstance(attempt, ConjectureResult)
+ if len(attempt.buffer) == len(self.current_data.buffer):
return False
for i, ex in enumerate(self.current_data.examples):
@@ -143,7 +154,7 @@ class Optimiser:
if ex.length == ex_attempt.length:
continue # pragma: no cover
replacement = attempt.buffer[ex_attempt.start : ex_attempt.end]
- if self.consider_new_test_data(
+ if self.consider_new_data(
self.engine.cached_test_function(
prefix
+ replacement
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
index a0043383720..d4418217876 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinker.py
@@ -9,7 +9,7 @@
# obtain one at https://mozilla.org/MPL/2.0/.
from collections import defaultdict
-from typing import TYPE_CHECKING, Callable, Dict, Optional, Union
+from typing import TYPE_CHECKING, Callable, Dict, Optional, Tuple, TypeVar, Union
import attr
@@ -38,10 +38,14 @@ from hypothesis.internal.conjecture.shrinking import (
)
if TYPE_CHECKING:
+ from random import Random
+
from hypothesis.internal.conjecture.engine import ConjectureRunner
+SortKeyT = TypeVar("SortKeyT", str, bytes)
+
-def sort_key(buffer):
+def sort_key(buffer: SortKeyT) -> Tuple[int, SortKeyT]:
"""Returns a sort key such that "simpler" buffers are smaller than
"more complicated" ones.
@@ -357,16 +361,16 @@ class Shrinker:
return self.passes_by_name[name]
@property
- def calls(self):
+ def calls(self) -> int:
"""Return the number of calls that have been made to the underlying
test function."""
return self.engine.call_count
@property
- def misaligned(self):
+ def misaligned(self) -> int:
return self.engine.misaligned_count
- def check_calls(self):
+ def check_calls(self) -> None:
if self.calls - self.calls_at_last_shrink >= self.max_stall:
raise StopShrinking
@@ -449,11 +453,11 @@ class Shrinker:
self.check_calls()
return result
- def debug(self, msg):
+ def debug(self, msg: str) -> None:
self.engine.debug(msg)
@property
- def random(self):
+ def random(self) -> "Random":
return self.engine.random
def shrink(self):
@@ -1068,10 +1072,11 @@ class Shrinker:
if node.was_forced:
return False # pragma: no cover
- if node.ir_type == "string":
+ if node.ir_type in {"string", "bytes"}:
+ size_kwarg = "min_size" if node.ir_type == "string" else "size"
# if the size *increased*, we would have to guess what to pad with
# in order to try fixing up this attempt. Just give up.
- if node.kwargs["min_size"] <= attempt_kwargs["min_size"]:
+ if node.kwargs[size_kwarg] <= attempt_kwargs[size_kwarg]:
return False
# the size decreased in our attempt. Try again, but replace with
# the min_size that we would have gotten, and truncate the value
@@ -1082,22 +1087,7 @@ class Shrinker:
initial_attempt[node.index].copy(
with_kwargs=attempt_kwargs,
with_value=initial_attempt[node.index].value[
- : attempt_kwargs["min_size"]
- ],
- )
- ]
- + initial_attempt[node.index :]
- )
- if node.ir_type == "bytes":
- if node.kwargs["size"] <= attempt_kwargs["size"]:
- return False
- return self.consider_new_tree(
- initial_attempt[: node.index]
- + [
- initial_attempt[node.index].copy(
- with_kwargs=attempt_kwargs,
- with_value=initial_attempt[node.index].value[
- : attempt_kwargs["size"]
+ : attempt_kwargs[size_kwarg]
],
)
]
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py
index 1de89bd18b8..b0c5ec8694e 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/conjecture/shrinking/common.py
@@ -38,10 +38,10 @@ class Shrinker:
self.debugging_enabled = debug
@property
- def calls(self):
+ def calls(self) -> int:
return len(self.__seen)
- def __repr__(self):
+ def __repr__(self) -> str:
return "{}({}initial={!r}, current={!r})".format(
type(self).__name__,
"" if self.name is None else f"{self.name!r}, ",
@@ -75,7 +75,7 @@ class Shrinker:
return other_class.shrink(initial, predicate, **kwargs)
- def debug(self, *args):
+ def debug(self, *args: object) -> None:
if self.debugging_enabled:
print("DEBUG", self, *args)
diff --git a/contrib/python/hypothesis/py3/hypothesis/internal/floats.py b/contrib/python/hypothesis/py3/hypothesis/internal/floats.py
index 6c4210e997b..79e6433dca8 100644
--- a/contrib/python/hypothesis/py3/hypothesis/internal/floats.py
+++ b/contrib/python/hypothesis/py3/hypothesis/internal/floats.py
@@ -11,22 +11,50 @@
import math
import struct
from sys import float_info
-from typing import Callable, Optional, SupportsFloat
+from typing import (
+ TYPE_CHECKING,
+ Callable,
+ Dict,
+ Literal,
+ Optional,
+ SupportsFloat,
+ Tuple,
+ Union,
+)
+
+if TYPE_CHECKING:
+ from typing import TypeAlias
+else:
+ TypeAlias = object
+
+SignedIntFormat: "TypeAlias" = Literal["!h", "!i", "!q"]
+UnsignedIntFormat: "TypeAlias" = Literal["!H", "!I", "!Q"]
+IntFormat: "TypeAlias" = Union[SignedIntFormat, UnsignedIntFormat]
+FloatFormat: "TypeAlias" = Literal["!e", "!f", "!d"]
+Width: "TypeAlias" = Literal[16, 32, 64]
# Format codes for (int, float) sized types, used for byte-wise casts.
# See https://docs.python.org/3/library/struct.html#format-characters
-STRUCT_FORMATS = {
+STRUCT_FORMATS: Dict[int, Tuple[UnsignedIntFormat, FloatFormat]] = {
16: ("!H", "!e"),
32: ("!I", "!f"),
64: ("!Q", "!d"),
}
+TO_SIGNED_FORMAT: Dict[UnsignedIntFormat, SignedIntFormat] = {
+ "!H": "!h",
+ "!I": "!i",
+ "!Q": "!q",
+}
+
-def reinterpret_bits(x, from_, to):
- return struct.unpack(to, struct.pack(from_, x))[0]
+def reinterpret_bits(x: float, from_: str, to: str) -> float:
+ x = struct.unpack(to, struct.pack(from_, x))[0]
+ assert isinstance(x, (float, int))
+ return x
-def float_of(x, width):
+def float_of(x: SupportsFloat, width: Width) -> float:
assert width in (16, 32, 64)
if width == 64:
return float(x)
@@ -45,7 +73,7 @@ def is_negative(x: SupportsFloat) -> bool:
) from None
-def count_between_floats(x, y, width=64):
+def count_between_floats(x: float, y: float, width: int = 64) -> int:
assert x <= y
if is_negative(x):
if is_negative(y):
@@ -59,17 +87,19 @@ def count_between_floats(x, y, width=64):
return float_to_int(y, width) - float_to_int(x, width) + 1
-def float_to_int(value, width=64):
+def float_to_int(value: float, width: int = 64) -> int:
fmt_int, fmt_flt = STRUCT_FORMATS[width]
- return reinterpret_bits(value, fmt_flt, fmt_int)
+ x = reinterpret_bits(value, fmt_flt, fmt_int)
+ assert isinstance(x, int)
+ return x
-def int_to_float(value, width=64):
+def int_to_float(value: int, width: int = 64) -> float:
fmt_int, fmt_flt = STRUCT_FORMATS[width]
return reinterpret_bits(value, fmt_int, fmt_flt)
-def next_up(value, width=64):
+def next_up(value: float, width: int = 64) -> float:
"""Return the first float larger than finite `val` - IEEE 754's `nextUp`.
From https://stackoverflow.com/a/10426033, with thanks to Mark Dickinson.
@@ -81,34 +111,34 @@ def next_up(value, width=64):
return 0.0
fmt_int, fmt_flt = STRUCT_FORMATS[width]
# Note: n is signed; float_to_int returns unsigned
- fmt_int = fmt_int.lower()
- n = reinterpret_bits(value, fmt_flt, fmt_int)
+ fmt_int_signed = TO_SIGNED_FORMAT[fmt_int]
+ n = reinterpret_bits(value, fmt_flt, fmt_int_signed)
if n >= 0:
n += 1
else:
n -= 1
- return reinterpret_bits(n, fmt_int, fmt_flt)
+ return reinterpret_bits(n, fmt_int_signed, fmt_flt)
-def next_down(value, width=64):
+def next_down(value: float, width: int = 64) -> float:
return -next_up(-value, width)
-def next_down_normal(value, width, allow_subnormal):
+def next_down_normal(value: float, width: int, *, allow_subnormal: bool) -> float:
value = next_down(value, width)
if (not allow_subnormal) and 0 < abs(value) < width_smallest_normals[width]:
return 0.0 if value > 0 else -width_smallest_normals[width]
return value
-def next_up_normal(value, width, allow_subnormal):
- return -next_down_normal(-value, width, allow_subnormal)
+def next_up_normal(value: float, width: int, *, allow_subnormal: bool) -> float:
+ return -next_down_normal(-value, width, allow_subnormal=allow_subnormal)
# Smallest positive non-zero numbers that is fully representable by an
# IEEE-754 float, calculated with the width's associated minimum exponent.
# Values from https://en.wikipedia.org/wiki/IEEE_754#Basic_and_interchange_formats
-width_smallest_normals = {
+width_smallest_normals: Dict[int, float] = {
16: 2 ** -(2 ** (5 - 1) - 2),
32: 2 ** -(2 ** (8 - 1) - 2),
64: 2 ** -(2 ** (11 - 1) - 2),
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
index 62dcecde207..7fdeedb4976 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/core.py
@@ -1295,6 +1295,12 @@ def _from_type(thing: Type[Ex]) -> SearchStrategy[Ex]:
if types.is_a_union(thing):
args = sorted(thing.__args__, key=types.type_sorting_key)
return one_of([_from_type(t) for t in args])
+ if thing in types.LiteralStringTypes: # pragma: no cover
+ # We can't really cover this because it needs either
+ # typing-extensions or python3.11+ typing.
+ # `LiteralString` from runtime's point of view is just a string.
+ # Fallback to regular text.
+ return text()
# We also have a special case for TypeVars.
# They are represented as instances like `~T` when they come here.
# We need to work with their type instead.
@@ -1340,27 +1346,68 @@ def _from_type(thing: Type[Ex]) -> SearchStrategy[Ex]:
or hasattr(types.typing_extensions, "_TypedDictMeta") # type: ignore
and type(thing) is types.typing_extensions._TypedDictMeta # type: ignore
): # pragma: no cover
+
+ def _get_annotation_arg(key, annotation_type):
+ try:
+ return get_args(annotation_type)[0]
+ except IndexError:
+ raise InvalidArgument(
+ f"`{key}: {annotation_type.__name__}` is not a valid type annotation"
+ ) from None
+
+ # Taken from `Lib/typing.py` and modified:
+ def _get_typeddict_qualifiers(key, annotation_type):
+ qualifiers = []
+ while True:
+ annotation_origin = types.extended_get_origin(annotation_type)
+ if annotation_origin in types.AnnotatedTypes:
+ if annotation_args := get_args(annotation_type):
+ annotation_type = annotation_args[0]
+ else:
+ break
+ elif annotation_origin in types.RequiredTypes:
+ qualifiers.append(types.RequiredTypes)
+ annotation_type = _get_annotation_arg(key, annotation_type)
+ elif annotation_origin in types.NotRequiredTypes:
+ qualifiers.append(types.NotRequiredTypes)
+ annotation_type = _get_annotation_arg(key, annotation_type)
+ elif annotation_origin in types.ReadOnlyTypes:
+ qualifiers.append(types.ReadOnlyTypes)
+ annotation_type = _get_annotation_arg(key, annotation_type)
+ else:
+ break
+ return set(qualifiers), annotation_type
+
# The __optional_keys__ attribute may or may not be present, but if there's no
# way to tell and we just have to assume that everything is required.
# See https://github.com/python/cpython/pull/17214 for details.
optional = set(getattr(thing, "__optional_keys__", ()))
+ required = set(
+ getattr(thing, "__required_keys__", get_type_hints(thing).keys())
+ )
anns = {}
for k, v in get_type_hints(thing).items():
- origin = get_origin(v)
- if origin in types.RequiredTypes + types.NotRequiredTypes:
- if origin in types.NotRequiredTypes:
- optional.add(k)
- else:
- optional.discard(k)
- try:
- v = v.__args__[0]
- except IndexError:
- raise InvalidArgument(
- f"`{k}: {v.__name__}` is not a valid type annotation"
- ) from None
+ qualifiers, v = _get_typeddict_qualifiers(k, v)
+ # We ignore `ReadOnly` type for now, only unwrap it.
+ if types.RequiredTypes in qualifiers:
+ optional.discard(k)
+ required.add(k)
+ if types.NotRequiredTypes in qualifiers:
+ optional.add(k)
+ required.discard(k)
+
anns[k] = from_type_guarded(v)
if anns[k] is ...:
anns[k] = _from_type_deferred(v)
+
+ if not required.isdisjoint(optional): # pragma: no cover
+ # It is impossible to cover, because `typing.py` or `typing-extensions`
+ # won't allow creating incorrect TypedDicts,
+ # this is just a sanity check from our side.
+ raise InvalidArgument(
+ f"Required keys overlap with optional keys in a TypedDict:"
+ f" {required=}, {optional=}"
+ )
if (
(not anns)
and thing.__annotations__
@@ -1368,7 +1415,7 @@ def _from_type(thing: Type[Ex]) -> SearchStrategy[Ex]:
):
raise InvalidArgument("Failed to retrieve type annotations for local type")
return fixed_dictionaries( # type: ignore
- mapping={k: v for k, v in anns.items() if k not in optional},
+ mapping={k: v for k, v in anns.items() if k in required},
optional={k: v for k, v in anns.items() if k in optional},
)
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/numbers.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/numbers.py
index 507cf879d63..033577f2c86 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/numbers.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/numbers.py
@@ -380,22 +380,30 @@ def floats(
if min_value is not None and (
exclude_min or (min_arg is not None and min_value < min_arg)
):
- min_value = next_up_normal(min_value, width, assumed_allow_subnormal)
+ min_value = next_up_normal(
+ min_value, width, allow_subnormal=assumed_allow_subnormal
+ )
if min_value == min_arg:
assert min_value == min_arg == 0
assert is_negative(min_arg)
assert not is_negative(min_value)
- min_value = next_up_normal(min_value, width, assumed_allow_subnormal)
+ min_value = next_up_normal(
+ min_value, width, allow_subnormal=assumed_allow_subnormal
+ )
assert min_value > min_arg # type: ignore
if max_value is not None and (
exclude_max or (max_arg is not None and max_value > max_arg)
):
- max_value = next_down_normal(max_value, width, assumed_allow_subnormal)
+ max_value = next_down_normal(
+ max_value, width, allow_subnormal=assumed_allow_subnormal
+ )
if max_value == max_arg:
assert max_value == max_arg == 0
assert is_negative(max_value)
assert not is_negative(max_arg)
- max_value = next_down_normal(max_value, width, assumed_allow_subnormal)
+ max_value = next_down_normal(
+ max_value, width, allow_subnormal=assumed_allow_subnormal
+ )
assert max_value < max_arg # type: ignore
if min_value == -math.inf:
diff --git a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
index 8753bfb7844..d5fef48aad6 100644
--- a/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
+++ b/contrib/python/hypothesis/py3/hypothesis/strategies/_internal/types.py
@@ -147,6 +147,49 @@ except AttributeError: # pragma: no cover
pass # `typing_extensions` might not be installed
+ReadOnlyTypes: tuple = ()
+try:
+ ReadOnlyTypes += (typing.ReadOnly,) # type: ignore
+except AttributeError: # pragma: no cover
+ pass # Is missing for `python<3.13`
+try:
+ ReadOnlyTypes += (typing_extensions.ReadOnly,)
+except AttributeError: # pragma: no cover
+ pass # `typing_extensions` might not be installed
+
+
+AnnotatedTypes: tuple = ()
+try:
+ AnnotatedTypes += (typing.Annotated,)
+except AttributeError: # pragma: no cover
+ pass # Is missing for `python<3.9`
+try:
+ AnnotatedTypes += (typing_extensions.Annotated,)
+except AttributeError: # pragma: no cover
+ pass # `typing_extensions` might not be installed
+
+
+LiteralStringTypes: tuple = ()
+try:
+ LiteralStringTypes += (typing.LiteralString,) # type: ignore
+except AttributeError: # pragma: no cover
+ pass # Is missing for `python<3.11`
+try:
+ LiteralStringTypes += (typing_extensions.LiteralString,)
+except AttributeError: # pragma: no cover
+ pass # `typing_extensions` might not be installed
+
+
+# We need this function to use `get_origin` on 3.8 for types added later:
+# in typing-extensions, so we prefer this function over regular `get_origin`
+# when unwrapping `TypedDict`'s annotations.
+try:
+ extended_get_origin = typing_extensions.get_origin
+except AttributeError: # pragma: no cover
+ # `typing_extensions` might not be installed, in this case - fallback:
+ extended_get_origin = get_origin # type: ignore
+
+
# 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
@@ -169,10 +212,10 @@ for name in (
"Self",
"Required",
"NotRequired",
+ "ReadOnly",
"Never",
"TypeVarTuple",
"Unpack",
- "LiteralString",
):
try:
NON_RUNTIME_TYPES += (getattr(typing, name),)
diff --git a/contrib/python/hypothesis/py3/hypothesis/version.py b/contrib/python/hypothesis/py3/hypothesis/version.py
index c8a8221c541..007af37ae6e 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, 108, 10)
+__version_info__ = (6, 110, 0)
__version__ = ".".join(map(str, __version_info__))
diff --git a/contrib/python/hypothesis/py3/ya.make b/contrib/python/hypothesis/py3/ya.make
index 8a025cf3596..7e33dc44974 100644
--- a/contrib/python/hypothesis/py3/ya.make
+++ b/contrib/python/hypothesis/py3/ya.make
@@ -2,7 +2,7 @@
PY3_LIBRARY()
-VERSION(6.108.10)
+VERSION(6.110.0)
LICENSE(MPL-2.0)