From 682bb5f562d68cb890a07c9640d2bd1b65b5d4fa Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 19 Apr 2023 15:12:28 -0600 Subject: [PATCH 1/6] Tweak settings docs --- hypothesis-python/docs/settings.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hypothesis-python/docs/settings.rst b/hypothesis-python/docs/settings.rst index 0086b9ea71..d7cdda09da 100644 --- a/hypothesis-python/docs/settings.rst +++ b/hypothesis-python/docs/settings.rst @@ -55,9 +55,9 @@ Controlling what runs Hypothesis divides tests into logically distinct phases: 1. Running explicit examples :ref:`provided with the @example decorator `. -2. Rerunning a selection of previously failing examples to reproduce a previously seen error +2. Rerunning a selection of previously failing examples to reproduce a previously seen error. 3. Generating new examples. -4. Mutating examples for :ref:`targeted property-based testing `. +4. Mutating examples for :ref:`targeted property-based testing ` (requires generate phase). 5. Attempting to shrink an example found in previous phases (other than phase 1 - explicit examples cannot be shrunk). This turns potentially large and complicated examples which may be hard to read into smaller and simpler ones. 6. Attempting to explain the cause of the failure, by identifying suspicious lines of code From 7d2e3a9a6426b0d650775ae984e2b54ba8c59b56 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 19 Apr 2023 15:12:29 -0600 Subject: [PATCH 2/6] Use implicit pprint stream --- hypothesis-python/src/hypothesis/core.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/hypothesis-python/src/hypothesis/core.py b/hypothesis-python/src/hypothesis/core.py index 049e16d3c5..f2696d50db 100644 --- a/hypothesis-python/src/hypothesis/core.py +++ b/hypothesis-python/src/hypothesis/core.py @@ -23,7 +23,6 @@ import zlib from collections import defaultdict from functools import partial -from io import StringIO from random import Random from typing import ( TYPE_CHECKING, @@ -793,9 +792,7 @@ def run(data): text_repr = repr_call(test, args, kwargs) if print_example or current_verbosity() >= Verbosity.verbose: - output = StringIO() - - printer = RepresentationPrinter(output, context=context) + printer = RepresentationPrinter(context=context) if print_example: printer.text("Falsifying example:") else: From 2239718091c6422ebf56c49dd480e3ceb1b687ff Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 19 Apr 2023 15:12:29 -0600 Subject: [PATCH 3/6] Add type hints --- .../src/hypothesis/internal/conjecture/shrinker.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py b/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py index 2ee5d5f4cb..c50117b98e 100644 --- a/hypothesis-python/src/hypothesis/internal/conjecture/shrinker.py +++ b/hypothesis-python/src/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 Dict +from typing import TYPE_CHECKING, Dict import attr @@ -19,7 +19,7 @@ prefix_selection_order, random_selection_order, ) -from hypothesis.internal.conjecture.data import ConjectureResult, Status +from hypothesis.internal.conjecture.data import ConjectureData, ConjectureResult, Status from hypothesis.internal.conjecture.floats import ( DRAW_FLOAT_LABEL, float_to_lex, @@ -33,6 +33,9 @@ from hypothesis.internal.conjecture.shrinking import Float, Integer, Lexical, Ordering from hypothesis.internal.conjecture.shrinking.learned_dfas import SHRINKING_DFAS +if TYPE_CHECKING: + from hypothesis.internal.conjecture.engine import ConjectureRunner + def sort_key(buffer): """Returns a sort key such that "simpler" buffers are smaller than @@ -268,7 +271,7 @@ def __init__(self, engine, initial, predicate, allow_transition): takes ConjectureData objects. """ assert predicate is not None or allow_transition is not None - self.engine = engine + self.engine: "ConjectureRunner" = engine self.__predicate = predicate or (lambda data: True) self.__allow_transition = allow_transition or (lambda source, destination: True) self.__derived_values = {} @@ -278,7 +281,7 @@ def __init__(self, engine, initial, predicate, allow_transition): # We keep track of the current best example on the shrink_target # attribute. - self.shrink_target = initial + self.shrink_target: ConjectureData = initial self.clear_change_tracking() self.shrinks = 0 From 42fc446e27178e63ef1c078a7f786f4e2e41d5bc Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 19 Apr 2023 15:12:30 -0600 Subject: [PATCH 4/6] Create RELEASE.rst --- hypothesis-python/RELEASE.rst | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 hypothesis-python/RELEASE.rst diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst new file mode 100644 index 0000000000..cb0fdfffbc --- /dev/null +++ b/hypothesis-python/RELEASE.rst @@ -0,0 +1,3 @@ +RELEASE_TYPE: patch + +This patch fixes some documentation and prepares for future features. From c20c7b9640934573053a32838e3e69ff1d38e65f Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Wed, 19 Apr 2023 15:12:30 -0600 Subject: [PATCH 5/6] Ensure full coverage --- hypothesis-python/tests/cover/test_database_backend.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hypothesis-python/tests/cover/test_database_backend.py b/hypothesis-python/tests/cover/test_database_backend.py index 2a96316822..1966dafffa 100644 --- a/hypothesis-python/tests/cover/test_database_backend.py +++ b/hypothesis-python/tests/cover/test_database_backend.py @@ -426,3 +426,11 @@ def values_agree(self, k): TestGADReads = GitHubArtifactMocks.TestCase + + +def test_gadb_coverage(): + # Ensure that we always cover the nonempty-archive case, which can otherwise + # cause rare incomplete-coverage failures. + state = GitHubArtifactMocks() + state.save(b"key", b"value") + state.values_agree(b"key") From 31e0d25918f5ea2de045ee2e69ae2158a9229809 Mon Sep 17 00:00:00 2001 From: CI on behalf of the Hypothesis team Date: Wed, 19 Apr 2023 21:02:04 +0000 Subject: [PATCH 6/6] Update pinned dependencies --- requirements/coverage.txt | 2 +- requirements/test.txt | 2 +- requirements/tools.txt | 18 +++++++++--------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/requirements/coverage.txt b/requirements/coverage.txt index 906c2e1131..d2d1c2ff29 100644 --- a/requirements/coverage.txt +++ b/requirements/coverage.txt @@ -6,7 +6,7 @@ # async-timeout==4.0.2 # via redis -attrs==22.2.0 +attrs==23.1.0 # via hypothesis (hypothesis-python/setup.py) black==23.3.0 # via -r requirements/coverage.in diff --git a/requirements/test.txt b/requirements/test.txt index fa4ca7a77d..9735af765b 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -4,7 +4,7 @@ # # ./build.sh upgrade-requirements # -attrs==22.2.0 +attrs==23.1.0 # via hypothesis (hypothesis-python/setup.py) exceptiongroup==1.1.1 ; python_version < "3.11" # via diff --git a/requirements/tools.txt b/requirements/tools.txt index 9951998657..c4794015b4 100644 --- a/requirements/tools.txt +++ b/requirements/tools.txt @@ -12,11 +12,11 @@ astor==0.8.1 # via flake8-simplify asttokens==2.2.1 # via stack-data -attrs==22.2.0 +attrs==23.1.0 # via # flake8-bugbear # hypothesis (hypothesis-python/setup.py) -autoflake==2.0.2 +autoflake==2.1.1 # via shed babel==2.12.1 # via sphinx @@ -79,7 +79,7 @@ exceptiongroup==1.1.1 ; python_version < "3.11" # pytest executing==1.2.0 # via stack-data -filelock==3.11.0 +filelock==3.12.0 # via # tox # virtualenv @@ -134,7 +134,7 @@ idna==3.4 # via requests imagesize==1.4.1 # via sphinx -importlib-metadata==6.4.1 +importlib-metadata==6.5.0 # via # keyring # twine @@ -230,7 +230,7 @@ pyflakes==3.0.1 # via # autoflake # flake8 -pygments==2.15.0 +pygments==2.15.1 # via # ipython # readme-renderer @@ -287,7 +287,7 @@ snowballstemmer==2.2.0 # sphinx sortedcontainers==2.4.0 # via hypothesis (hypothesis-python/setup.py) -soupsieve==2.4 +soupsieve==2.4.1 # via beautifulsoup4 sphinx==6.1.3 # via @@ -296,7 +296,7 @@ sphinx==6.1.3 # sphinx-hoverxref # sphinx-rtd-theme # sphinxcontrib-jquery -sphinx-codeautolink==0.14.1 +sphinx-codeautolink==0.15.0 # via -r requirements/tools.in sphinx-hoverxref==1.3.0 # via -r requirements/tools.in @@ -320,7 +320,7 @@ sphinxcontrib-qthelp==1.0.3 # via sphinx sphinxcontrib-serializinghtml==1.1.5 # via sphinx -sqlparse==0.4.3 +sqlparse==0.4.4 # via django stack-data==0.6.2 # via ipython @@ -370,7 +370,7 @@ urllib3==1.26.15 # via # requests # twine -virtualenv==20.21.0 +virtualenv==20.21.1 # via tox wcwidth==0.2.6 # via prompt-toolkit