Skip to content

Commit cc69401

Browse files
committed
move pairwise to compat
1 parent a8a11b3 commit cc69401

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

hypothesis-python/src/hypothesis/internal/compat.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import copy
1313
import dataclasses
1414
import inspect
15+
import itertools
1516
import platform
1617
import sys
1718
import sysconfig
@@ -251,6 +252,20 @@ def bad_django_TestCase(runner):
251252
return not isinstance(runner, HypothesisTestCase)
252253

253254

255+
if sys.version_info[:2] < (3, 10):
256+
257+
# copied straight from
258+
# https://docs.python.org/3/library/itertools.html#itertools.pairwise
259+
def pairwise(iterable):
260+
iterator = iter(iterable)
261+
a = next(iterator, None)
262+
for b in iterator:
263+
yield a, b
264+
a = b
265+
266+
else:
267+
pairwise = itertools.pairwise
268+
254269
# see issue #3812
255270
if sys.version_info[:2] < (3, 12):
256271

hypothesis-python/src/hypothesis/internal/conjecture/junkdrawer.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
import array
1616
import sys
1717
import warnings
18-
from itertools import chain, pairwise
18+
from itertools import chain
1919
from random import Random
2020
from typing import (
2121
Callable,
@@ -35,6 +35,7 @@
3535
from sortedcontainers import SortedList
3636

3737
from hypothesis.errors import HypothesisWarning
38+
from hypothesis.internal.compat import pairwise
3839

3940
ARRAY_CODES = ["B", "H", "I", "L", "Q", "O"]
4041

0 commit comments

Comments
 (0)