Repository: HypothesisWorks/hypothesis

Issue:
Warnings in Python 3.8 (CPython master)
Trying to install hypothesis shows the following warning in CPython master. I searched for the related warning and master branch but I couldn't find any issue so I am reporting it here.


> /home/karthi/pandas-venv/lib/python3.8/site-packages/hypothesis/strategies.py:32: DeprecationWarning: Using or importing the ABCs from 'collections' instead of from 'collections.abc' is deprecated, and in 3.8 it will stop working
  from collections import Sequence


Thanks


Discussion:
Thanks for reporting this!  Would you like to open a PR and fix it?

The patch will consist of deleting that import, prepending `abc` to the names imported from `hypothesis.internal.compat` (line 42), and replacing the only runtime use of `Sequence` with `abc.Sequence` (line 973).  Then add a `RELEASE.rst` for a patch release (copy from one of my open PRs, and see the changelog for message style), add your name to the list of authors in `CONTRIBUTING.rst`, and we're done!
Sure, thanks for the information. I will raise a PR by the weekend.

Thanks

Resolving patch:
diff --git a/hypothesis-python/src/hypothesis/internal/conjecture/utils.py b/hypothesis-python/src/hypothesis/internal/conjecture/utils.py
--- a/hypothesis-python/src/hypothesis/internal/conjecture/utils.py
+++ b/hypothesis-python/src/hypothesis/internal/conjecture/utils.py
@@ -22,11 +22,11 @@
 import heapq
 import hashlib
 from fractions import Fraction
-from collections import Sequence, OrderedDict
+from collections import OrderedDict
 
 from hypothesis._settings import note_deprecation
-from hypothesis.internal.compat import floor, hbytes, hrange, qualname, \
-    bit_length, str_to_bytes, int_from_bytes
+from hypothesis.internal.compat import abc, floor, hbytes, hrange, \
+    qualname, bit_length, str_to_bytes, int_from_bytes
 from hypothesis.internal.floats import int_to_float
 
 LABEL_MASK = 2 ** 64 - 1
@@ -126,7 +126,7 @@ def check_sample(values, strategy_name):
                 'want to sample slices.  Sampling a multi-dimensional '
                 'array will be an error in a future version of Hypothesis.'
             ).format(ndim=values.ndim, shape=values.shape))
-    elif not isinstance(values, (OrderedDict, Sequence, enum.EnumMeta)):
+    elif not isinstance(values, (OrderedDict, abc.Sequence, enum.EnumMeta)):
         note_deprecation(
             'Cannot sample from {values}, not an ordered collection. '
             'Hypothesis goes to some length to ensure that the {strategy} '
diff --git a/hypothesis-python/src/hypothesis/strategies.py b/hypothesis-python/src/hypothesis/strategies.py
--- a/hypothesis-python/src/hypothesis/strategies.py
+++ b/hypothesis-python/src/hypothesis/strategies.py
@@ -29,7 +29,6 @@
 from inspect import isclass, isfunction
 from fractions import Fraction
 from functools import reduce
-from collections import Sequence
 
 import attr
 
@@ -39,7 +38,7 @@
 from hypothesis._settings import note_deprecation
 from hypothesis.internal.cache import LRUReusedCache
 from hypothesis.searchstrategy import SearchStrategy, check_strategy
-from hypothesis.internal.compat import gcd, ceil, floor, hrange, \
+from hypothesis.internal.compat import abc, gcd, ceil, floor, hrange, \
     string_types, get_type_hints, getfullargspec, typing_root_type, \
     implements_iterator
 from hypothesis.internal.floats import next_up, float_of, next_down, \
@@ -970,7 +969,7 @@ def text(
     elif isinstance(alphabet, SearchStrategy):
         char_strategy = alphabet
     else:
-        if not isinstance(alphabet, Sequence):
+        if not isinstance(alphabet, abc.Sequence):
             note_deprecation(
                 'alphabet must be an ordered sequence, or tests may be '
                 'flaky and shrinking weaker, but a %r is not a type of '
diff --git a/tooling/src/hypothesistooling/projects/hypothesispython.py b/tooling/src/hypothesistooling/projects/hypothesispython.py
--- a/tooling/src/hypothesistooling/projects/hypothesispython.py
+++ b/tooling/src/hypothesistooling/projects/hypothesispython.py
@@ -161,7 +161,7 @@ def upload_distribution():
         ),
         timeout=120,  # seconds
         # Scoped personal access token, stored in Travis environ variable
-        auth=('Zac-HD', os.environ['Zac-release-token']),
+        auth=('Zac-HD', os.environ['Zac_release_token']),
     ).raise_for_status()
 
 


Test patch: