From 9af938d7fb3d8a4a487195da3836b0285347985f Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Mon, 11 Mar 2024 06:55:40 +0100 Subject: [PATCH 1/7] Fix unimplemented default TypeVar argument in 3.13a4 --- .../src/hypothesis/strategies/_internal/strategies.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py b/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py index d8d6be91ae..4d2ef61abc 100644 --- a/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py +++ b/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py @@ -52,7 +52,8 @@ from hypothesis.strategies._internal.utils import defines_strategy from hypothesis.utils.conventions import UniqueIdentifier -if sys.version_info >= (3, 13): +# TODO: Use `(3, 13)` once Python 3.13 is released. +if sys.version_info >= (3, 13, 0, "final"): Ex = TypeVar("Ex", covariant=True, default=Any) elif TYPE_CHECKING: from typing_extensions import TypeVar # type: ignore[assignment] From 81dff666396c1e35a8dd94e1db7f618a866812f6 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Mon, 11 Mar 2024 08:17:21 +0100 Subject: [PATCH 2/7] Add 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..55bdd27a61 --- /dev/null +++ b/hypothesis-python/RELEASE.rst @@ -0,0 +1,3 @@ +RELEASE_TYPE: patch + +Fix regression caused by using :pep:`696` default in TypeVar with Python 3.13a4. From ecb4e14932cec1ef2a6757b170da65ab5666f12c Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:15:11 +0100 Subject: [PATCH 3/7] Enable Python 3.13 CI tests --- .github/workflows/main.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 895694d956..ecf66b5570 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -46,7 +46,9 @@ jobs: - check-py312-cover - check-py312-nocover - check-py312-niche - # - check-py313-cover + - check-py313-cover + - check-py313-nocover + - check-py313-niche - check-quality ## Skip all the (inactive/old) Rust and Ruby tests pending fixes # - lint-ruby From 465a70fecf008e7d6bf901fd79469c3562263684 Mon Sep 17 00:00:00 2001 From: Jonathan Plasse <13716151+JonathanPlasse@users.noreply.github.com> Date: Mon, 11 Mar 2024 14:26:12 +0100 Subject: [PATCH 4/7] Fix mypy errors --- .../src/hypothesis/strategies/_internal/strategies.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py b/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py index 4d2ef61abc..448f7e51ac 100644 --- a/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py +++ b/hypothesis-python/src/hypothesis/strategies/_internal/strategies.py @@ -58,7 +58,7 @@ elif TYPE_CHECKING: from typing_extensions import TypeVar # type: ignore[assignment] - Ex = TypeVar("Ex", covariant=True, default=Any) + Ex = TypeVar("Ex", covariant=True, default=Any) # type: ignore[call-arg,misc] else: Ex = TypeVar("Ex", covariant=True) From 168df5d56181405b8921d1823dad7cc450851739 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Mon, 11 Mar 2024 11:15:49 -0700 Subject: [PATCH 5/7] Exact version --- hypothesis-python/RELEASE.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hypothesis-python/RELEASE.rst b/hypothesis-python/RELEASE.rst index 55bdd27a61..b5cd6079c2 100644 --- a/hypothesis-python/RELEASE.rst +++ b/hypothesis-python/RELEASE.rst @@ -1,3 +1,3 @@ RELEASE_TYPE: patch -Fix regression caused by using :pep:`696` default in TypeVar with Python 3.13a4. +Fix regression caused by using :pep:`696` default in TypeVar with Python 3.13.0a3. From 341a0ddcf99ba485993abcf8c563d9af4617a30f Mon Sep 17 00:00:00 2001 From: Liam DeVoe Date: Mon, 11 Mar 2024 12:46:09 -0400 Subject: [PATCH 6/7] deflake test_can_generate_hard_values --- hypothesis-python/tests/conjecture/test_data_tree.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hypothesis-python/tests/conjecture/test_data_tree.py b/hypothesis-python/tests/conjecture/test_data_tree.py index eccbcfc5ec..d0b62e4752 100644 --- a/hypothesis-python/tests/conjecture/test_data_tree.py +++ b/hypothesis-python/tests/conjecture/test_data_tree.py @@ -519,16 +519,13 @@ def buf(data): data.draw_integer(min_value, max_value) data.freeze() - @run_to_buffer - def expected_buf(data): - data.draw_integer(min_value, max_value, forced=max_value) - data.mark_interesting() - # this test doubles as conjecture coverage for using our child cache, so # ensure we don't miss that logic by getting lucky and drawing the correct # value once or twice. for _ in range(20): - assert tree.generate_novel_prefix(Random()) == expected_buf + prefix = tree.generate_novel_prefix(Random()) + data = ConjectureData.for_buffer(prefix) + assert data.draw_integer(min_value, max_value) == 1000 def test_can_generate_hard_floats(): From c94c97db43b1e9469b97c5a693d71457caa6fbe1 Mon Sep 17 00:00:00 2001 From: Zac Hatfield-Dodds Date: Mon, 11 Mar 2024 11:26:53 -0700 Subject: [PATCH 7/7] Skip eval'd-lambda tests on py3.13 for now --- hypothesis-python/tests/cover/test_filter_rewriting.py | 5 +++++ hypothesis-python/tests/cover/test_lambda_formatting.py | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/hypothesis-python/tests/cover/test_filter_rewriting.py b/hypothesis-python/tests/cover/test_filter_rewriting.py index ab4ec78f19..a2d9a1bf90 100644 --- a/hypothesis-python/tests/cover/test_filter_rewriting.py +++ b/hypothesis-python/tests/cover/test_filter_rewriting.py @@ -12,6 +12,7 @@ import math import operator import re +import sys from fractions import Fraction from functools import partial from sys import float_info @@ -34,6 +35,10 @@ A_FEW = 15 # speed up massively-parametrized tests +# FIXME-3.13: something about get_lambda_source not working with pytest-xdist? +if sys.version_info[:2] == (3, 13) and sys.version_info.releaselevel < "final": + pytest.skip(allow_module_level=True) + @pytest.mark.parametrize( "strategy, predicate, start, end", diff --git a/hypothesis-python/tests/cover/test_lambda_formatting.py b/hypothesis-python/tests/cover/test_lambda_formatting.py index 380e19710e..b30438cf51 100644 --- a/hypothesis-python/tests/cover/test_lambda_formatting.py +++ b/hypothesis-python/tests/cover/test_lambda_formatting.py @@ -8,6 +8,10 @@ # 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/. +import sys + +import pytest + from hypothesis.internal.reflection import get_pretty_function_description @@ -15,6 +19,7 @@ def test_bracket_whitespace_is_striped(): assert get_pretty_function_description(lambda x: (x + 1)) == "lambda x: (x + 1)" +@pytest.mark.skipif(sys.version_info[:2] == (3, 13), reason="FIXME-3.13") def test_no_whitespace_before_colon_with_no_args(): assert get_pretty_function_description(eval("lambda: None")) == "lambda: " @@ -58,6 +63,7 @@ def test_variable_names_are_not_pretty(): assert get_pretty_function_description(t) == "lambda x: True" +@pytest.mark.skipif(sys.version_info[:2] == (3, 13), reason="FIXME-3.13") def test_does_not_error_on_dynamically_defined_functions(): x = eval("lambda t: 1") get_pretty_function_description(x)