Update to 6.49.1

This commit is contained in:
Miro Hrončok 2022-07-07 01:08:45 +02:00
parent b1e6a5f589
commit 41029d28de
5 changed files with 2 additions and 153 deletions

View File

@ -1,70 +0,0 @@
From 2484942b4f9ff63e6c3c0dae2097a266622fc87d Mon Sep 17 00:00:00 2001
From: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Date: Wed, 22 Jun 2022 22:41:38 -0700
Subject: [PATCH] Support 3.11 GenericAlias again
---
hypothesis-python/RELEASE.rst | 4 ++++
.../src/hypothesis/strategies/_internal/types.py | 13 +++++--------
2 files changed, 9 insertions(+), 8 deletions(-)
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..6b49da62d3
--- /dev/null
+++ b/hypothesis-python/RELEASE.rst
@@ -0,0 +1,4 @@
+RELEASE_TYPE: patch
+
+This patch fixes :func:`~hypothesis.strategies.from_type` on Python 3.11,
+following `python/cpython#93754 <https://github.com/python/cpython/pull/93754/>`__.
diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/types.py b/hypothesis-python/src/hypothesis/strategies/_internal/types.py
index 617b360856..4e410bcf58 100644
--- a/hypothesis-python/src/hypothesis/strategies/_internal/types.py
+++ b/hypothesis-python/src/hypothesis/strategies/_internal/types.py
@@ -39,11 +39,13 @@
from hypothesis.strategies._internal.lazy import unwrap_strategies
from hypothesis.strategies._internal.strategies import OneOfStrategy
+GenericAlias: typing.Any
UnionType: typing.Any
try:
# The type of PEP-604 unions (`int | str`), added in Python 3.10
- from types import UnionType
+ from types import GenericAlias, UnionType
except ImportError:
+ GenericAlias = ()
UnionType = ()
try:
@@ -51,11 +53,6 @@
except ImportError:
typing_extensions = None # type: ignore
-try:
- from typing import _GenericAlias # type: ignore # python >= 3.7
-except ImportError:
- _GenericAlias = ()
-
try:
from typing import _AnnotatedAlias # type: ignore
except ImportError:
@@ -298,7 +295,7 @@ def find_annotated_strategy(annotated_type): # pragma: no cover
def has_type_arguments(type_):
"""Decides whethere or not this type has applied type arguments."""
args = getattr(type_, "__args__", None)
- if args and isinstance(type_, _GenericAlias):
+ if args and isinstance(type_, (typing._GenericAlias, GenericAlias)):
# There are some cases when declared types do already have type arguments
# Like `Sequence`, that is `_GenericAlias(abc.Sequence[T])[T]`
parameters = getattr(type_, "__parameters__", None)
@@ -312,7 +309,7 @@ def is_generic_type(type_):
# The ugly truth is that `MyClass`, `MyClass[T]`, and `MyClass[int]` are very different.
# We check for `MyClass[T]` and `MyClass[int]` with the first condition,
# while the second condition is for `MyClass`.
- return isinstance(type_, typing_root_type) or (
+ return isinstance(type_, typing_root_type + (GenericAlias,)) or (
isinstance(type_, type) and typing.Generic in type_.__mro__
)

View File

@ -1,34 +0,0 @@
From 6d1d17d016d092146b620e4f9338f9b125e33ded Mon Sep 17 00:00:00 2001
From: Florian Bruhin <me@the-compiler.org>
Date: Tue, 26 Apr 2022 11:16:27 +0200
Subject: [PATCH] Adjust imports of deprecated sre_* modules in Python 3.11
Fixes #3309
See https://github.com/python/cpython/issues/91308
I don't see a way to avoid relying on Python 3.11 internals here, so
this instead just adjusts the imports to avoid deprecation warnings.
---
.../src/hypothesis/strategies/_internal/regex.py | 9 +++++++--
1 file changed, 7 insertions(+), 2 deletions(-)
diff --git a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
index 5da2b3ba2d..b93e8d192b 100644
--- a/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
+++ b/hypothesis-python/src/hypothesis/strategies/_internal/regex.py
@@ -10,8 +10,13 @@
import operator
import re
-import sre_constants as sre
-import sre_parse
+
+try: # pragma: no cover
+ import re._constants as sre
+ import re._parser as sre_parse
+except ImportError: # Python < 3.11
+ import sre_constants as sre # type: ignore
+ import sre_parse # type: ignore
from hypothesis import reject, strategies as st
from hypothesis.internal.charmap import as_general_categories, categories

View File

@ -1,42 +0,0 @@
From a4681f6962ea137db3eec059fb453929eb998fec Mon Sep 17 00:00:00 2001
From: Zac Hatfield-Dodds <zac.hatfield.dodds@gmail.com>
Date: Sat, 7 May 2022 23:45:33 -0600
Subject: [PATCH] Tests work on 3.11.0b1
Thanks to CPython upstream fixes, these tests should now just work
---
hypothesis-python/tests/conftest.py | 5 -----
hypothesis-python/tests/cover/test_lookup_py37.py | 4 ----
2 files changed, 9 deletions(-)
diff --git a/hypothesis-python/tests/conftest.py b/hypothesis-python/tests/conftest.py
index 988efaf70c..bcbd024903 100644
--- a/hypothesis-python/tests/conftest.py
+++ b/hypothesis-python/tests/conftest.py
@@ -37,11 +37,6 @@
if sys.version_info >= (3, 11):
collect_ignore_glob.append("cover/test_asyncio.py") # @asyncio.coroutine removed
- assert sys.version_info.releaselevel == "alpha"
- # TODO: our traceback elision doesn't work with Python 3.11's nice new format yet
- collect_ignore_glob.append("cover/test_traceback_elision.py")
- collect_ignore_glob.append("pytest/test_capture.py")
-
def pytest_configure(config):
config.addinivalue_line("markers", "slow: pandas expects this marker to exist.")
diff --git a/hypothesis-python/tests/cover/test_lookup_py37.py b/hypothesis-python/tests/cover/test_lookup_py37.py
index bdfbbecd9e..6a1955eb6b 100644
--- a/hypothesis-python/tests/cover/test_lookup_py37.py
+++ b/hypothesis-python/tests/cover/test_lookup_py37.py
@@ -163,10 +163,6 @@ def test_resolving_standard_callable_ellipsis(x: collections.abc.Callable[..., E
assert isinstance(x(1, 2, 3, a=4, b=5, c=6), Elem)
-@pytest.mark.skipif(
- sys.version_info[:3] == (3, 11, 0),
- reason="https://github.com/python/cpython/issues/91621",
-)
@given(...)
def test_resolving_standard_callable_no_args(x: collections.abc.Callable[[], Elem]):
assert isinstance(x, collections.abc.Callable)

View File

@ -9,7 +9,7 @@
%endif
Name: python-hypothesis
Version: 6.45.0
Version: 6.49.1
Release: %autorelease
Summary: Library for property based testing
@ -17,11 +17,6 @@ License: MPLv2.0
URL: https://github.com/HypothesisWorks/hypothesis
Source0: %{url}/archive/hypothesis-python-%{version}/hypothesis-%{version}.tar.gz
# Python 3.11 fixes
Patch: https://github.com/HypothesisWorks/hypothesis/commit/6d1d17d016.patch
Patch: https://github.com/HypothesisWorks/hypothesis/commit/a4681f6962.patch
Patch: https://github.com/HypothesisWorks/hypothesis/commit/2484942b4f.patch
BuildArch: noarch
BuildRequires: python%{python3_pkgversion}-devel

View File

@ -1 +1 @@
SHA512 (hypothesis-6.45.0.tar.gz) = 01e4aea5ce71c476fbee52182ff07529126744eb8bb603175370d33d2e1ce49a367ef2c0ec7abf879ed2bfa25a31e1b2136e2b79bc68d4a4c200cc3159583c6c
SHA512 (hypothesis-6.49.1.tar.gz) = 14b232ad1b2c233566d26eae2be1557ce543109748b5f835f74acbc9aad6aba2d75e4f9c357ee6dbc3bc75e175413058b4796d2853921c23ff083d66424cf7b4