Skip to content

Commit

Permalink
Merge pull request #3794 from HypothesisWorks/create-pull-request/patch
Browse files Browse the repository at this point in the history
Update pinned dependencies
  • Loading branch information
Zac-HD committed Nov 20, 2023
2 parents 0b7d1c2 + b5ce73a commit 04d86cc
Show file tree
Hide file tree
Showing 13 changed files with 86 additions and 49 deletions.
15 changes: 15 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
RELEASE_TYPE: minor

This release makes it an error to assign ``settings = settings(...)``
as a class attribute on a :class:`~hypothesis.stateful.RuleBasedStateMachine`.
This has never had any effect, and it should be used as a decorator instead:

.. code-block: python
class BadMachine(RuleBasedStateMachine):
"""This doesn't do anything, and is now an error!"""
settings = settings(derandomize=True)
@settings(derandomize=True)
class GoodMachine(RuleBasedStateMachine):
"""This is the right way to do it :-)"""
8 changes: 4 additions & 4 deletions hypothesis-python/src/hypothesis/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,10 +610,10 @@ def get_random_for_wrapped_test(test, wrapped_test):

@attr.s
class Stuff:
selfy = attr.ib(default=None)
args = attr.ib(factory=tuple)
kwargs = attr.ib(factory=dict)
given_kwargs = attr.ib(factory=dict)
selfy: Any = attr.ib(default=None)
args: tuple = attr.ib(factory=tuple)
kwargs: dict = attr.ib(factory=dict)
given_kwargs: dict = attr.ib(factory=dict)


def process_arguments_to_given(wrapped_test, arguments, kwargs, given_kwargs, params):
Expand Down
2 changes: 1 addition & 1 deletion hypothesis-python/src/hypothesis/extra/numpy.py
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ def array_dtypes(
field_names,
st.tuples(field_names, field_names).filter(lambda ns: ns[0] != ns[1]),
)
elements = st.tuples(name_titles, subtype_strategy)
elements: st.SearchStrategy[tuple] = st.tuples(name_titles, subtype_strategy)
if allow_subarrays:
elements |= st.tuples(
name_titles, subtype_strategy, array_shapes(max_dims=2, max_side=2)
Expand Down
14 changes: 12 additions & 2 deletions hypothesis-python/src/hypothesis/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,9 +220,10 @@ def run_state_machine(factory, data):
class StateMachineMeta(type):
def __setattr__(cls, name, value):
if name == "settings" and isinstance(value, Settings):
descr = f"settings({value.show_changed()})"
raise AttributeError(
f"Assigning {cls.__name__}.settings = {value} does nothing. Assign "
f"to {cls.__name__}.TestCase.settings, or use @{value} as a decorator "
f"Assigning {cls.__name__}.settings = {descr} does nothing. Assign "
f"to {cls.__name__}.TestCase.settings, or use @{descr} as a decorator "
f"on the {cls.__name__} class."
)
return super().__setattr__(name, value)
Expand Down Expand Up @@ -255,6 +256,15 @@ def __init__(self) -> None:
self._initialize_rules_to_run = copy(self.initialize_rules())
self._rules_strategy = RuleStrategy(self)

if isinstance(s := vars(type(self)).get("settings"), Settings):
tname = type(self).__name__
descr = f"settings({s.show_changed()})"
raise InvalidDefinition(
f"Assigning settings = {descr} as a class attribute does nothing. "
f"Assign to {tname}.TestCase.settings, or use @{descr} as a decorator "
f"on the {tname} class."
)

def _pretty_print(self, value):
if isinstance(value, VarReference):
return value.name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,9 @@
}


GROUP_CACHE_STRATEGY = st.shared(st.builds(dict), key="hypothesis.regex.group_cache")
GROUP_CACHE_STRATEGY: st.SearchStrategy[dict] = st.shared(
st.builds(dict), key="hypothesis.regex.group_cache"
)


@st.composite
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ def _networks(bits):
st.binary(),
st.integers(0, 255),
# As with Reversible, we tuplize this for compatibility with Hashable.
st.lists(st.integers(0, 255)).map(tuple), # type: ignore
st.lists(st.integers(0, 255)).map(tuple),
),
typing.BinaryIO: st.builds(io.BytesIO, st.binary()),
typing.TextIO: st.builds(io.StringIO, st.text()),
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Version 2023111100, Last Updated Sat Nov 11 07:07:01 2023 UTC
# Version 2023111800, Last Updated Sat Nov 18 07:07:01 2023 UTC
AAA
AARP
ABB
Expand Down Expand Up @@ -379,7 +379,6 @@ ES
ESQ
ESTATE
ET
ETISALAT
EU
EUROVISION
EUS
Expand Down Expand Up @@ -1370,7 +1369,6 @@ XN--MGB9AWBF
XN--MGBA3A3EJT
XN--MGBA3A4F16A
XN--MGBA7C0BBN0A
XN--MGBAAKC7DVF
XN--MGBAAM7A8H
XN--MGBAB2BD
XN--MGBAH1A3HJKRD
Expand Down
16 changes: 16 additions & 0 deletions hypothesis-python/tests/cover/test_stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -1215,3 +1215,19 @@ def test_min_steps_argument():

# (oh, and it's OK if you ask for more than we're actually going to take)
run_state_machine_as_test(MinStepsMachine, _min_steps=20)


class ErrorsOnClassAttributeSettings(RuleBasedStateMachine):
settings = Settings(derandomize=True)

@rule()
def step(self):
pass


def test_fails_on_settings_class_attribute():
with pytest.raises(
InvalidDefinition,
match="Assigning .+ as a class attribute does nothing",
):
run_state_machine_as_test(ErrorsOnClassAttributeSettings)
10 changes: 5 additions & 5 deletions requirements/coverage.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ async-timeout==4.0.3
# via redis
attrs==23.1.0
# via hypothesis (hypothesis-python/setup.py)
black==23.10.1
black==23.11.0
# via -r requirements/coverage.in
click==8.1.7
# via
Expand Down Expand Up @@ -38,21 +38,21 @@ mypy-extensions==1.0.0
# via
# black
# typing-inspect
numpy==1.26.1
numpy==1.26.2
# via
# -r requirements/coverage.in
# pandas
packaging==23.2
# via
# black
# pytest
pandas==2.1.2
pandas==2.1.3
# via -r requirements/coverage.in
pathspec==0.11.2
# via black
pexpect==4.8.0
# via -r requirements/test.in
platformdirs==3.11.0
platformdirs==4.0.0
# via black
pluggy==1.3.0
# via pytest
Expand All @@ -62,7 +62,7 @@ pytest==7.4.3
# via
# -r requirements/test.in
# pytest-xdist
pytest-xdist==3.3.1
pytest-xdist==3.4.0
# via -r requirements/test.in
python-dateutil==2.8.2
# via
Expand Down
22 changes: 12 additions & 10 deletions requirements/fuzzing.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#
# ./build.sh upgrade-requirements
#
annotated-types==0.6.0
# via -r requirements/coverage.in
ansi2html==1.8.0
# via dash
async-timeout==4.0.3
Expand All @@ -12,14 +14,14 @@ attrs==23.1.0
# via
# hypothesis
# hypothesis (hypothesis-python/setup.py)
black==23.10.1
black==23.11.0
# via
# -r requirements/coverage.in
# hypofuzz
# hypothesis
blinker==1.7.0
# via flask
certifi==2023.7.22
certifi==2023.11.17
# via requests
charset-normalizer==3.3.2
# via requests
Expand Down Expand Up @@ -56,7 +58,7 @@ flask==3.0.0
# via dash
hypofuzz==23.7.1
# via -r requirements/fuzzing.in
hypothesis[cli]==6.88.1
hypothesis[cli]==6.89.0
# via
# hypofuzz
# hypothesis
Expand Down Expand Up @@ -90,7 +92,7 @@ mypy-extensions==1.0.0
# typing-inspect
nest-asyncio==1.5.8
# via dash
numpy==1.26.1
numpy==1.26.2
# via
# -r requirements/coverage.in
# pandas
Expand All @@ -99,15 +101,15 @@ packaging==23.2
# black
# plotly
# pytest
pandas==2.1.2
pandas==2.1.3
# via
# -r requirements/coverage.in
# hypofuzz
pathspec==0.11.2
# via black
pexpect==4.8.0
# via -r requirements/test.in
platformdirs==3.11.0
platformdirs==4.0.0
# via black
plotly==5.18.0
# via dash
Expand All @@ -117,14 +119,14 @@ psutil==5.9.6
# via hypofuzz
ptyprocess==0.7.0
# via pexpect
pygments==2.16.1
pygments==2.17.0
# via rich
pytest==7.4.3
# via
# -r requirements/test.in
# hypofuzz
# pytest-xdist
pytest-xdist==3.3.1
pytest-xdist==3.4.0
# via -r requirements/test.in
python-dateutil==2.8.2
# via
Expand All @@ -144,7 +146,7 @@ requests==2.31.0
# hypofuzz
retrying==1.3.4
# via dash
rich==13.6.0
rich==13.7.0
# via hypothesis
six==1.16.0
# via
Expand Down Expand Up @@ -172,7 +174,7 @@ typing-inspect==0.9.0
# via libcst
tzdata==2023.3
# via pandas
urllib3==2.0.7
urllib3==2.1.0
# via requests
werkzeug==3.0.1
# via
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pytest==7.4.3
# via
# -r requirements/test.in
# pytest-xdist
pytest-xdist==3.3.1
pytest-xdist==3.4.0
# via -r requirements/test.in
sortedcontainers==2.4.0
# via hypothesis (hypothesis-python/setup.py)
Expand Down
24 changes: 12 additions & 12 deletions requirements/tools.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ babel==2.13.1
# via sphinx
beautifulsoup4==4.12.2
# via sphinx-codeautolink
black==23.10.1
black==23.11.0
# via shed
build==1.0.3
# via pip-tools
cachetools==5.3.2
# via tox
certifi==2023.7.22
certifi==2023.11.17
# via requests
cffi==1.16.0
# via cryptography
Expand Down Expand Up @@ -98,7 +98,7 @@ jeepney==0.8.0
# secretstorage
jinja2==3.1.2
# via sphinx
keyring==24.2.0
keyring==24.3.0
# via twine
lark==1.1.8
# via -r requirements/tools.in
Expand All @@ -116,7 +116,7 @@ mdurl==0.1.2
# via markdown-it-py
more-itertools==10.1.0
# via jaraco-classes
mypy==1.6.1
mypy==1.7.0
# via -r requirements/tools.in
mypy-extensions==1.0.0
# via
Expand Down Expand Up @@ -154,7 +154,7 @@ pluggy==1.3.0
# via
# pytest
# tox
prompt-toolkit==3.0.39
prompt-toolkit==3.0.41
# via ipython
ptyprocess==0.7.0
# via pexpect
Expand All @@ -164,7 +164,7 @@ pycparser==2.21
# via cffi
pyflakes==3.1.0
# via autoflake
pygments==2.16.1
pygments==2.17.0
# via
# ipython
# readme-renderer
Expand All @@ -174,7 +174,7 @@ pyproject-api==1.6.1
# via tox
pyproject-hooks==1.0.0
# via build
pyright==1.1.334
pyright==1.1.336
# via -r requirements/tools.in
pytest==7.4.3
# via -r requirements/tools.in
Expand All @@ -198,9 +198,9 @@ restructuredtext-lint==1.4.0
# via -r requirements/tools.in
rfc3986==2.0.0
# via twine
rich==13.6.0
rich==13.7.0
# via twine
ruff==0.1.3
ruff==0.1.6
# via -r requirements/tools.in
secretstorage==3.3.3
# via keyring
Expand Down Expand Up @@ -285,7 +285,7 @@ types-pyopenssl==23.3.0.0
# via types-redis
types-pytz==2023.3.1.1
# via -r requirements/tools.in
types-redis==4.6.0.9
types-redis==4.6.0.10
# via -r requirements/tools.in
typing-extensions==4.8.0
# via
Expand All @@ -297,13 +297,13 @@ typing-extensions==4.8.0
# typing-inspect
typing-inspect==0.9.0
# via libcst
urllib3==2.0.7
urllib3==2.1.0
# via
# requests
# twine
virtualenv==20.24.6
# via tox
wcwidth==0.2.9
wcwidth==0.2.10
# via prompt-toolkit
wheel==0.41.3
# via pip-tools
Expand Down
Loading

0 comments on commit 04d86cc

Please sign in to comment.