Skip to content

Commit

Permalink
Merge pull request #3917 from JonathanPlasse/fix-typevar-default-unav…
Browse files Browse the repository at this point in the history
…ailable-on-3.13.0.alpha.4

Fix unimplemented default TypeVar argument in 3.13a4
  • Loading branch information
Zac-HD committed Mar 11, 2024
2 parents d739e0d + c94c97d commit 479448d
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 9 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions hypothesis-python/RELEASE.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RELEASE_TYPE: patch

Fix regression caused by using :pep:`696` default in TypeVar with Python 3.13.0a3.
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,13 @@
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]

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)

Expand Down
9 changes: 3 additions & 6 deletions hypothesis-python/tests/conjecture/test_data_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down
5 changes: 5 additions & 0 deletions hypothesis-python/tests/cover/test_filter_rewriting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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",
Expand Down
6 changes: 6 additions & 0 deletions hypothesis-python/tests/cover/test_lambda_formatting.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,18 @@
# 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


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: <unknown>"

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 479448d

Please sign in to comment.