Repository navigation
Closed
Labels
bugsomething is clearly wrong heresomething is clearly wrong here
Description
In order to account for changes to the Python typing module made by python/cpython@d911e40 I am applying the following patch which may be ok, but more likely is not (the typing module is not something with which I am at all familiar):
From 27a17ef17be0e518ac06152442966e4dbb193fc5 Mon Sep 17 00:00:00 2001
From: Ray Donnelly <[email protected]>
Date: Tue, 1 May 2018 16:45:42 +0100
Subject: [PATCH] Fix typing _ForwardRef and TypingMeta for Python 3.7
These fixes are likely incorrect though.
---
hypothesis-python/src/hypothesis/strategies.py | 13 +++++++++++--
1 file changed, 11 insertions(+), 2 deletions(-)
diff --git a/hypothesis-python/src/hypothesis/strategies.py b/hypothesis-python/src/hypothesis/strategies.py
index e324784b..82ebe842 100644
--- a/hypothesis-python/src/hypothesis/strategies.py
+++ b/hypothesis-python/src/hypothesis/strategies.py
@@ -1067,6 +1067,11 @@ def from_type(thing):
from hypothesis.searchstrategy import types
try:
import typing
+ # Since https://github.com/python/cpython/commit/d911e40e788fb679723d78b6ea11cabf46caed5a
+ if hasattr(typing, '_ForwardRef'):
+ typing_ForwardRef = typing._ForwardRef
+ else:
+ typing_ForwardRef = typing.ForwardRef
if not isinstance(thing, type):
# At runtime, `typing.NewType` returns an identity function rather
# than an actual type, but we can check that for a possible match
@@ -1083,7 +1088,7 @@ def from_type(thing):
return one_of([from_type(t) for t in args])
# We can't resolve forward references, and under Python 3.5 (only)
# a forward reference is an instance of type. Hence, explicit check:
- elif type(thing) == typing._ForwardRef: # pragma: no cover
+ elif type(thing) == typing_ForwardRef: # pragma: no cover
raise ResolutionFailed(
'thing=%s cannot be resolved. Upgrading to python>=3.6 may '
'fix this problem via improvements to the typing module.'
@@ -1112,7 +1117,11 @@ def from_type(thing):
# subclass and instance checks.
try:
import typing
- if isinstance(thing, typing.TypingMeta):
+ if hasattr(typing, 'TypingMeta'):
+ typing_TypeVar = typing.TypingMeta
+ else:
+ typing_TypeVar = typing.TypeVar
+ if isinstance(thing, typing_TypeVar):
return types.from_typing_type(thing)
except ImportError: # pragma: no cover
pass
--
2.17.0Best regards.
Metadata
Metadata
Assignees
Labels
bugsomething is clearly wrong heresomething is clearly wrong here
Activity
mingwandroid commentedon May 1, 2018
If you need a build of Python 3.7.0b3 (and 207 python packages) against which to test
hypothesis, and you are a user of theAnaconda DistributionandmacOS, you can useconda create -n py27 -c c3i_test python=3.7(other OSes to follow).Zac-HD commentedon May 2, 2018
Thanks for reporting this! Compatibility bugs are always a high priority for us 😄
@DRMacIver / @alexwlchan, can one of you help out with #1148?
typingmodule changes are explicitly called out there (in fact we would have caught this earlier), but my attempt to add it to CI failed 😭I'm not keen to merge a fix before it can be tested, but with that out of the way this will be at the top of my list.
mingwandroid commentedon May 2, 2018
Can/do you use
minicondain your CI? If so you could usec3i_testto get Python 3.7.0b3.mingwandroid commentedon Jun 29, 2018
Is there any progress on this? Python 3.7 has been released now.
DRMacIver commentedon Jun 29, 2018
It has, but the release situation is frankly terrible and we're not sure what to do about it. 😢
The hard dependency on a new version of OpenSSL means that the release basically doesn't work on any of our CI infrastructure, and we're not able to fix that without making everything substantially worse or doing a bunch of build engineering to build OpenSSL ourself, which we haven't found time for yet.
mingwandroid commentedon Jul 15, 2018
Maybe try
conda?, we handle all of that stuff for you.mingwandroid commentedon Jul 15, 2018
https://github.com/conda-forge/hypothesis-feedstock
Zac-HD commentedon Jul 15, 2018
Ah, thanks - I've now got a working conda environment set up and I'm starting to work through the long list of test failures. So far this is mostly just a matter of adding compatibility shims for renamed or changed objects such as "the class everything in
typinginherits from" 🙄. Hopefully this is the last time...