Skip to content

Commit 7839707

Browse files
authored
Merge pull request #3471 from HypothesisWorks/create-pull-request/patch
Update pinned dependencies
2 parents 576a3c7 + 4c94bf4 commit 7839707

File tree

14 files changed

+92
-38
lines changed

14 files changed

+92
-38
lines changed

.github/workflows/main.yml

+1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
- check-django41
5757
- check-django40
5858
- check-django32
59+
- check-pandas15
5960
- check-pandas14
6061
- check-pandas13
6162
- check-pandas12

hypothesis-python/RELEASE.rst

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
RELEASE_TYPE: minor
2+
3+
This release defines ``__bool__()`` on :class:`~hypothesis.strategies.SearchStrategy`.
4+
It always returns ``True``, like before, but also emits a warning to help with
5+
cases where you intended to draw a value (:issue:`3463`).

hypothesis-python/docs/conf.py

+11
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,17 @@ def setup(app):
8282
# See https://sphinx-hoverxref.readthedocs.io/en/latest/configuration.html
8383
hoverxref_auto_ref = True
8484
hoverxref_domains = ["py"]
85+
hoverxref_role_types = {
86+
"attr": "tooltip",
87+
"class": "tooltip",
88+
"const": "tooltip",
89+
"exc": "tooltip",
90+
"func": "tooltip",
91+
"meth": "tooltip",
92+
"mod": "tooltip",
93+
"obj": "tooltip",
94+
"ref": "tooltip",
95+
}
8596

8697
intersphinx_mapping = {
8798
"python": ("https://docs.python.org/3/", None),

hypothesis-python/docs/details.rst

+13
Original file line numberDiff line numberDiff line change
@@ -420,6 +420,19 @@ there is a natural metric like "floating-point error", "load factor" or
420420

421421
.. autofunction:: hypothesis.target
422422

423+
.. code-block:: python
424+
425+
from hypothesis import given, strategies as st, target
426+
427+
428+
@given(st.floats(0, 1e100), st.floats(0, 1e100), st.floats(0, 1e100))
429+
def test_associativity_with_target(a, b, c):
430+
ab_c = (a + b) + c
431+
a_bc = a + (b + c)
432+
difference = abs(ab_c - a_bc)
433+
target(difference) # Without this, the test almost always passes
434+
assert difference < 2.0
435+
423436
We recommend that users also skim the papers introducing targeted PBT;
424437
from `ISSTA 2017 <http://proper.softlab.ntua.gr/papers/issta2017.pdf>`__
425438
and `ICST 2018 <http://proper.softlab.ntua.gr/papers/icst2018.pdf>`__.

hypothesis-python/docs/extras.rst

+5-5
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,12 @@ There are separate pages for :doc:`django` and :doc:`numpy`.
2828
.. automodule:: hypothesis.extra.dpcontracts
2929
:members:
3030

31-
.. tip::
31+
.. tip::
3232

33-
For new projects, we recommend using either :pypi:`deal` or :pypi:`icontract`
34-
and :pypi:`icontract-hypothesis` over :pypi:`dpcontracts`.
35-
They're generally more powerful tools for design-by-contract programming,
36-
and have substantially nicer Hypothesis integration too!
33+
For new projects, we recommend using either :pypi:`deal` or :pypi:`icontract`
34+
and :pypi:`icontract-hypothesis` over :pypi:`dpcontracts`.
35+
They're generally more powerful tools for design-by-contract programming,
36+
and have substantially nicer Hypothesis integration too!
3737

3838
.. automodule:: hypothesis.extra.lark
3939
:members:

hypothesis-python/docs/numpy.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Supported versions
4747
There is quite a lot of variation between pandas versions. We only
4848
commit to supporting the latest version of pandas, but older minor versions are
4949
supported on a "best effort" basis. Hypothesis is currently tested against
50-
and confirmed working with every Pandas minor version from 1.0 through to 1.4.
50+
and confirmed working with every Pandas minor version from 1.0 through to 1.5.
5151

5252
Releases that are not the latest patch release of their minor version are not
5353
tested or officially supported, but will probably also work unless you hit a

hypothesis-python/setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def local_file(name):
6666
# zoneinfo is an odd one: every dependency is conditional, because they're
6767
# only necessary on old versions of Python or Windows systems.
6868
"zoneinfo": [
69-
"tzdata>=2022.2 ; sys_platform == 'win32'",
69+
"tzdata>=2022.4 ; sys_platform == 'win32'",
7070
"backports.zoneinfo>=0.2.1 ; python_version<'3.9'",
7171
],
7272
# We only support Django versions with upstream support - see

hypothesis-python/src/hypothesis/extra/array_api.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ def find_castable_builtin_for_dtype(
163163

164164

165165
@check_function
166-
def dtype_from_name(xp: Any, name: str) -> DataType:
166+
def dtype_from_name(xp: Any, name: str) -> Any:
167167
if name in DTYPE_NAMES:
168168
try:
169169
return getattr(xp, name)

hypothesis-python/src/hypothesis/strategies/_internal/strategies.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
from hypothesis.control import _current_build_context, assume
3030
from hypothesis.errors import (
3131
HypothesisException,
32+
HypothesisWarning,
3233
InvalidArgument,
3334
NonInteractiveExampleWarning,
3435
UnsatisfiedAssumption,
@@ -396,6 +397,14 @@ def __or__(self, other: "SearchStrategy[T]") -> "SearchStrategy[Union[Ex, T]]":
396397
raise ValueError(f"Cannot | a SearchStrategy with {other!r}")
397398
return OneOfStrategy((self, other))
398399

400+
def __bool__(self) -> bool:
401+
warnings.warn(
402+
f"bool({self!r}) is always True, did you mean to draw a value?",
403+
HypothesisWarning,
404+
stacklevel=2,
405+
)
406+
return True
407+
399408
def validate(self) -> None:
400409
"""Throw an exception if the strategy is not valid.
401410
@@ -589,7 +598,7 @@ def do_filtered_draw(self, data):
589598
return filter_not_satisfied
590599

591600

592-
class OneOfStrategy(SearchStrategy):
601+
class OneOfStrategy(SearchStrategy[Ex]):
593602
"""Implements a union of strategies. Given a number of strategies this
594603
generates values which could have come from any of them.
595604
@@ -781,7 +790,7 @@ def one_of(
781790
return OneOfStrategy(args)
782791

783792

784-
class MappedSearchStrategy(SearchStrategy):
793+
class MappedSearchStrategy(SearchStrategy[Ex]):
785794
"""A strategy which is defined purely by conversion to and from another
786795
strategy.
787796
@@ -816,7 +825,7 @@ def pack(self, x):
816825
into a value suitable for outputting from this strategy."""
817826
raise NotImplementedError(f"{self.__class__.__name__}.pack()")
818827

819-
def do_draw(self, data: ConjectureData) -> Ex:
828+
def do_draw(self, data: ConjectureData) -> Any:
820829
with warnings.catch_warnings():
821830
if isinstance(self.pack, type) and issubclass(
822831
self.pack, (abc.Mapping, abc.Set)
@@ -826,7 +835,7 @@ def do_draw(self, data: ConjectureData) -> Ex:
826835
i = data.index
827836
try:
828837
data.start_example(MAPPED_SEARCH_STRATEGY_DO_DRAW_LABEL)
829-
result = self.pack(data.draw(self.mapped_strategy))
838+
result = self.pack(data.draw(self.mapped_strategy)) # type: ignore
830839
data.stop_example()
831840
return result
832841
except UnsatisfiedAssumption:
@@ -846,7 +855,7 @@ def branches(self) -> List[SearchStrategy[Ex]]:
846855
filter_not_satisfied = UniqueIdentifier("filter not satisfied")
847856

848857

849-
class FilteredStrategy(SearchStrategy):
858+
class FilteredStrategy(SearchStrategy[Ex]):
850859
def __init__(self, strategy, conditions):
851860
super().__init__()
852861
if isinstance(strategy, FilteredStrategy):

hypothesis-python/tests/cover/test_error_in_draw.py

+11
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import pytest
1212

1313
from hypothesis import given, strategies as st
14+
from hypothesis.errors import HypothesisWarning
1415

1516

1617
def test_error_is_in_finally():
@@ -25,3 +26,13 @@ def test(d):
2526
test()
2627

2728
assert "[0, 1, -1]" in "\n".join(err.value.__notes__)
29+
30+
31+
@given(st.data())
32+
def test_warns_on_bool_strategy(data):
33+
with pytest.warns(
34+
HypothesisWarning,
35+
match=r"bool\(.+\) is always True, did you mean to draw a value\?",
36+
):
37+
if st.booleans(): # 'forgot' to draw from the strategy
38+
pass

hypothesis-python/tox.ini

+8-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ commands=
4343

4444
# Note: when adding or removing tested Pandas versions, make sure to update the
4545
# docs in numpy.rst too. To see current download rates of each minor version:
46-
# https://pepy.tech/project/pandas?versions=0.25.*&versions=1.0.*&versions=1.1.*&versions=1.2.*&versions=1.3.*&versions=1.4.*
46+
# https://pepy.tech/project/pandas?versions=1.0.*&versions=1.1.*&versions=1.2.*&versions=1.3.*&versions=1.4.*&versions=1.5.*
4747
[testenv:pandas10]
4848
deps =
4949
-r../requirements/test.txt
@@ -78,6 +78,13 @@ deps =
7878
pandas~=1.4.3
7979
commands =
8080
python -bb -X dev -m pytest tests/pandas -n auto
81+
82+
[testenv:pandas15]
83+
deps =
84+
-r../requirements/test.txt
85+
pandas~=1.5.0
86+
commands =
87+
python -bb -X dev -m pytest tests/pandas -n auto
8188
# Adding a new pandas? See comment above!
8289

8390
[testenv:django32]

requirements/coverage.txt

+4-6
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ click==8.1.3
1818
# via
1919
# -r requirements/coverage.in
2020
# black
21-
coverage==6.4.4
21+
coverage==6.5.0
2222
# via -r requirements/coverage.in
2323
deprecated==1.2.13
2424
# via redis
@@ -28,7 +28,7 @@ exceptiongroup==1.0.0rc9 ; python_version < "3.11"
2828
# via hypothesis (hypothesis-python/setup.py)
2929
execnet==1.9.0
3030
# via pytest-xdist
31-
fakeredis==1.9.1
31+
fakeredis==1.9.3
3232
# via -r requirements/coverage.in
3333
iniconfig==1.1.1
3434
# via pytest
@@ -48,7 +48,7 @@ packaging==21.3
4848
# via
4949
# pytest
5050
# redis
51-
pandas==1.4.4
51+
pandas==1.5.0
5252
# via -r requirements/coverage.in
5353
pathspec==0.10.1
5454
# via black
@@ -88,9 +88,7 @@ pyyaml==6.0
8888
redis==4.3.4
8989
# via fakeredis
9090
six==1.16.0
91-
# via
92-
# fakeredis
93-
# python-dateutil
91+
# via python-dateutil
9492
sortedcontainers==2.4.0
9593
# via
9694
# fakeredis

requirements/tools.txt

+16-17
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ attrs==22.1.0
1717
# flake8-bugbear
1818
# hypothesis (hypothesis-python/setup.py)
1919
# pytest
20-
autoflake==1.5.3
20+
autoflake==1.6.1
2121
# via shed
2222
babel==2.10.3
2323
# via sphinx
@@ -35,7 +35,7 @@ bleach==5.0.1
3535
# via readme-renderer
3636
build==0.8.0
3737
# via pip-tools
38-
certifi==2022.9.14
38+
certifi==2022.9.24
3939
# via requests
4040
cffi==1.15.1
4141
# via cryptography
@@ -51,7 +51,7 @@ com2ann==0.3.0
5151
# via shed
5252
commonmark==0.9.1
5353
# via rich
54-
coverage==6.4.4
54+
coverage==6.5.0
5555
# via -r requirements/tools.in
5656
cryptography==38.0.1
5757
# via secretstorage
@@ -71,7 +71,7 @@ dpcontracts==0.6.0
7171
# via -r requirements/tools.in
7272
exceptiongroup==1.0.0rc9 ; python_version < "3.11"
7373
# via hypothesis (hypothesis-python/setup.py)
74-
executing==1.0.0
74+
executing==1.1.0
7575
# via stack-data
7676
filelock==3.8.0
7777
# via
@@ -94,7 +94,7 @@ flake8-2020==1.7.0
9494
# via -r requirements/tools.in
9595
flake8-bandit==4.1.1
9696
# via -r requirements/tools.in
97-
flake8-bugbear==22.9.11
97+
flake8-bugbear==22.9.23
9898
# via -r requirements/tools.in
9999
flake8-builtins==1.5.3
100100
# via -r requirements/tools.in
@@ -128,7 +128,7 @@ idna==3.4
128128
# via requests
129129
imagesize==1.4.1
130130
# via sphinx
131-
importlib-metadata==4.12.0
131+
importlib-metadata==4.13.0
132132
# via
133133
# keyring
134134
# sphinx
@@ -139,7 +139,7 @@ ipython==8.5.0
139139
# via -r requirements/tools.in
140140
isort==5.10.1
141141
# via shed
142-
jaraco-classes==3.2.2
142+
jaraco-classes==3.2.3
143143
# via keyring
144144
jedi==0.18.1
145145
# via ipython
@@ -165,7 +165,7 @@ mccabe==0.7.0
165165
# via flake8
166166
more-itertools==8.14.0
167167
# via jaraco-classes
168-
mypy==0.971
168+
mypy==0.981
169169
# via -r requirements/tools.in
170170
mypy-extensions==0.4.3
171171
# via
@@ -232,21 +232,21 @@ pygments==2.13.0
232232
# sphinx
233233
pyparsing==3.0.9
234234
# via packaging
235-
pyright==1.1.271
235+
pyright==1.1.273
236236
# via -r requirements/tools.in
237237
pytest==7.1.3
238238
# via -r requirements/tools.in
239239
python-dateutil==2.8.2
240240
# via -r requirements/tools.in
241241
pytz==2022.2.1
242242
# via babel
243-
pyupgrade==2.38.0
243+
pyupgrade==2.38.2
244244
# via shed
245245
pyyaml==6.0
246246
# via
247247
# bandit
248248
# libcst
249-
readme-renderer==37.1
249+
readme-renderer==37.2
250250
# via twine
251251
requests==2.28.1
252252
# via
@@ -282,7 +282,7 @@ sortedcontainers==2.4.0
282282
# via hypothesis (hypothesis-python/setup.py)
283283
soupsieve==2.3.2.post1
284284
# via beautifulsoup4
285-
sphinx==5.1.1
285+
sphinx==5.2.3
286286
# via
287287
# -r requirements/tools.in
288288
# sphinx-codeautolink
@@ -308,18 +308,17 @@ sphinxcontrib-qthelp==1.0.3
308308
# via sphinx
309309
sphinxcontrib-serializinghtml==1.1.5
310310
# via sphinx
311-
sqlparse==0.4.2
311+
sqlparse==0.4.3
312312
# via django
313-
stack-data==0.5.0
313+
stack-data==0.5.1
314314
# via ipython
315315
stevedore==4.0.0
316316
# via bandit
317317
tokenize-rt==4.2.1
318318
# via pyupgrade
319-
toml==0.10.2
320-
# via autoflake
321319
tomli==2.0.1
322320
# via
321+
# autoflake
323322
# black
324323
# build
325324
# mypy
@@ -340,7 +339,7 @@ types-pkg-resources==0.1.3
340339
# via -r requirements/tools.in
341340
types-pytz==2022.2.1.0
342341
# via -r requirements/tools.in
343-
types-redis==4.3.20
342+
types-redis==4.3.21
344343
# via -r requirements/tools.in
345344
typing-extensions==4.3.0
346345
# via

tooling/src/hypothesistooling/__main__.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ def standard_tox_task(name):
440440

441441
for n in [32, 40, 41]:
442442
standard_tox_task(f"django{n}")
443-
for n in [10, 11, 12, 13, 14]:
443+
for n in [10, 11, 12, 13, 14, 15]:
444444
standard_tox_task(f"pandas{n}")
445445

446446
standard_tox_task("coverage")

0 commit comments

Comments
 (0)