Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pinned dependencies #3872

Merged
merged 2 commits into from
Feb 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,7 @@ bytes from:

```python
class TestData:
def draw_bytes(self, n):
...
def draw_bytes(self, n): ...
```

(note: The Python code in this article isn't an exact copy of what's
Expand Down Expand Up @@ -237,8 +236,7 @@ distribution hint:

```python
class TestData:
def draw_bytes(self, n, distribution=None):
...
def draw_bytes(self, n, distribution=None): ...
```

Where a distribution function takes a Random object
Expand Down Expand Up @@ -328,14 +326,11 @@ looks like this:

```python
class TestData:
def start_interval(self):
...
def start_interval(self): ...

def stop_interval(self):
...
def stop_interval(self): ...

def draw_bytes(self, n):
...
def draw_bytes(self, n): ...

def draw(self, strategy):
self.start_interval()
Expand Down
4 changes: 4 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
RELEASE_TYPE: patch

This patch updates our vendored `list of top-level domains <https://www.iana.org/domains/root/db>`__,
which is used by the provisional :func:`~hypothesis.provisional.domains` strategy.
9 changes: 3 additions & 6 deletions hypothesis-python/docs/details.rst
Original file line number Diff line number Diff line change
Expand Up @@ -524,8 +524,7 @@ transformation before applying :func:`@given <hypothesis.given>`.

@given(x=integers())
@pytest.mark.trio
async def test(x):
...
async def test(x): ...


# Illustrative code, inside the pytest-trio plugin
Expand Down Expand Up @@ -677,8 +676,7 @@ supported use-case, again on a best-effort provisional basis. For example:

.. code:: python

def foo_strategy() -> SearchStrategy[Foo]:
...
def foo_strategy() -> SearchStrategy[Foo]: ...

.. class:: hypothesis.strategies.SearchStrategy

Expand Down Expand Up @@ -752,8 +750,7 @@ converting bytestrings into your objects by hand?
.. code:: python

@given(st.text())
def test_foo(s):
...
def test_foo(s): ...


# This is a traditional fuzz target - call it with a bytestring,
Expand Down
6 changes: 2 additions & 4 deletions hypothesis-python/docs/reproducing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,11 @@ same examples each time they are executed, thanks to ``@seed()``:
@seed(1234)
@given(x=...)
def test(x):
...
def test(x): ...
@seed(6789)
class MyModel(RuleBasedStateMachine):
...
class MyModel(RuleBasedStateMachine): ...
The seed will not be printed if you could simply use ``@example`` instead.

Expand Down
24 changes: 14 additions & 10 deletions hypothesis-python/src/hypothesis/extra/_patching.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,16 +94,20 @@ def __call_node_to_example_dec(self, node, via):
# 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 :-/
Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/extra/codemods.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,9 +218,11 @@ def leave_Call(self, original_node, updated_node):
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)
Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/extra/ghostwriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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})"
Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/extra/pandas/impl.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,9 +346,11 @@ def result(draw):
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),
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1578,9 +1578,11 @@ def as_result(self) -> Union[ConjectureResult, _Overrun]:
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),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,10 @@ def __len__(self):
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):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -627,16 +627,16 @@ def explain(self):
# 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):
Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/internal/escalation.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,11 @@ def from_exception(cls, exception: BaseException, /) -> "InterestingOrigin":
# 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 ()
),
)


Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/provisional.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
),
Expand Down
8 changes: 5 additions & 3 deletions hypothesis-python/src/hypothesis/strategies/_internal/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1835,9 +1835,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()
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/vendor/pretty.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -96,7 +96,6 @@ BA
BABY
BAIDU
BANAMEX
BANANAREPUBLIC
BAND
BANK
BAR
Expand Down Expand Up @@ -855,7 +854,6 @@ OFFICE
OKINAWA
OLAYAN
OLAYANGROUP
OLDNAVY
OLLO
OM
OMEGA
Expand Down
3 changes: 1 addition & 2 deletions hypothesis-python/tests/conjecture/test_shrinker.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,7 @@ def shrinker(data):
data.stop_example()
data.start_example(1)
interesting = (
data.draw_integer(0, 2**8 - 1) > 0
and data.draw_integer(0, 2**16 - 1) > 0
data.draw_integer(0, 2**8 - 1) > 0 and data.draw_integer(0, 2**16 - 1) > 0
)
data.stop_example()
if interesting:
Expand Down
6 changes: 4 additions & 2 deletions hypothesis-python/tests/cover/test_filter_rewriting.py
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,8 @@ def test_filter_rewriting_text_partial_len(data, strategy, predicate, start, end
s = strategy.filter(predicate)

assert isinstance(s, LazyStrategy)
assert isinstance(inner := unwrap_strategies(s), TextStrategy)
inner = unwrap_strategies(s)
assert isinstance(inner, TextStrategy)
assert inner.min_size == start
assert inner.max_size == end
value = data.draw(s)
Expand All @@ -427,7 +428,8 @@ def test_can_rewrite_multiple_length_filters_if_not_lambdas(data):
.filter(partial(max_len, 4))
)
assert isinstance(s, LazyStrategy)
assert isinstance(inner := unwrap_strategies(s), TextStrategy)
inner = unwrap_strategies(s)
assert isinstance(inner, TextStrategy)
assert inner.min_size == 2
assert inner.max_size == 4
value = data.draw(s)
Expand Down
6 changes: 2 additions & 4 deletions hypothesis-python/tests/cover/test_lookup.py
Original file line number Diff line number Diff line change
Expand Up @@ -1056,8 +1056,7 @@ def test_constructor_is_more_important(data):
data.draw(st.builds(AnnotatedConstructor))


def use_signature(self, value: str) -> None:
...
def use_signature(self, value: str) -> None: ...


class AnnotatedConstructorWithSignature(typing.Generic[_ValueType]):
Expand All @@ -1070,8 +1069,7 @@ def __init__(self, value: int) -> None:
assert isinstance(value, str)


def selfless_signature(value: str) -> None:
...
def selfless_signature(value: str) -> None: ...


class AnnotatedConstructorWithSelflessSignature(AnnotatedConstructorWithSignature):
Expand Down
3 changes: 1 addition & 2 deletions hypothesis-python/tests/cover/test_lookup_py39.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,7 @@ def test_can_register_builtin_list():

@typing.runtime_checkable
class Fooable(typing.Protocol[T]):
def foo(self):
...
def foo(self): ...


class FooableConcrete(tuple):
Expand Down
8 changes: 2 additions & 6 deletions hypothesis-python/tests/cover/test_regex.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,16 +183,12 @@ def test_any_doesnt_generate_newline():

@pytest.mark.parametrize("pattern", [re.compile("\\A.\\Z", re.DOTALL), "(?s)\\A.\\Z"])
def test_any_with_dotall_generate_newline(pattern):
find_any(
st.from_regex(pattern), lambda s: s == "\n", settings(max_examples=10**6)
)
find_any(st.from_regex(pattern), lambda s: s == "\n", settings(max_examples=10**6))


@pytest.mark.parametrize("pattern", [re.compile(b"\\A.\\Z", re.DOTALL), b"(?s)\\A.\\Z"])
def test_any_with_dotall_generate_newline_binary(pattern):
find_any(
st.from_regex(pattern), lambda s: s == b"\n", settings(max_examples=10**6)
)
find_any(st.from_regex(pattern), lambda s: s == b"\n", settings(max_examples=10**6))


@pytest.mark.parametrize(
Expand Down
4 changes: 1 addition & 3 deletions hypothesis-python/tests/cover/test_slices.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ def test_slices_will_shrink(size):
@given(st.integers(1, 1000))
@settings(deadline=None)
def test_step_will_be_negative(size):
find_any(
st.slices(size), lambda x: (x.step or 1) < 0, settings(max_examples=10**6)
)
find_any(st.slices(size), lambda x: (x.step or 1) < 0, settings(max_examples=10**6))


@given(st.integers(1, 1000))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ from hypothesis import given, strategies as st


class TestFuzzCompile(unittest.TestCase):

@given(pattern=st.text(), flags=st.just(0))
def test_fuzz_compile(self, pattern, flags):
re.compile(pattern=pattern, flags=flags)
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ from hypothesis import given, reject, strategies as st, target


class TestEquivalentSortedSorted(unittest.TestCase):

@given(
iterable=st.one_of(st.iterables(st.integers()), st.iterables(st.text())),
key=st.none(),
Expand Down
Loading
Loading