diff --git a/.github/workflows/wheels.yml b/.github/workflows/wheels.yml index e884545..5e82960 100644 --- a/.github/workflows/wheels.yml +++ b/.github/workflows/wheels.yml @@ -170,7 +170,7 @@ jobs: steps: - name: Setup QEMU if: ${{ matrix.os == 'ubuntu' }} - uses: docker/setup-qemu-action@v2 + uses: docker/setup-qemu-action@v3 with: platforms: all - name: Checkout @@ -182,7 +182,7 @@ jobs: with: python-version: "3.x" - name: Build wheels - uses: pypa/cibuildwheel@v2.14.1 + uses: pypa/cibuildwheel@v2.16.2 env: CIBW_BUILD: ${{ matrix.build }} CIBW_ARCHS: ${{ matrix.arch }} @@ -237,7 +237,7 @@ jobs: run: | ls -al dist/ - name: Publish to PyPI - uses: pypa/gh-action-pypi-publish@v1.8.8 + uses: pypa/gh-action-pypi-publish@v1.8.11 if: startsWith(github.ref, 'refs/tags/') with: user: __token__ diff --git a/cytoolz/tests/test_functoolz.py b/cytoolz/tests/test_functoolz.py index 47484f6..a459dad 100644 --- a/cytoolz/tests/test_functoolz.py +++ b/cytoolz/tests/test_functoolz.py @@ -1,4 +1,5 @@ import inspect +import sys import cytoolz from cytoolz.functoolz import (thread_first, thread_last, memoize, curry, compose, compose_left, pipe, complement, do, juxt, @@ -7,6 +8,12 @@ from cytoolz.utils import raises from functools import partial +IS_PYPY_GE_39 = ( + sys.implementation.name == "pypy" + and sys.version_info.major == 3 + and sys.version_info.minor >= 9 +) + def iseven(x): return x % 2 == 0 @@ -253,7 +260,8 @@ def f(x, y): return x g = curry(f) - assert g.__doc__ == f.__doc__ + if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property + assert g.__doc__ == f.__doc__ assert str(g) == str(f) assert f(1, 2) == g(1, 2) @@ -582,14 +590,16 @@ def g(a): composed = compose(f, g) assert composed.__name__ == 'f_of_g' - assert composed.__doc__ == 'lambda *args, **kwargs: f(g(*args, **kwargs))' + if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property + assert composed.__doc__ == 'lambda *args, **kwargs: f(g(*args, **kwargs))' # Create an object with no __name__. h = object() composed = compose(f, h) assert composed.__name__ == 'Compose' - assert composed.__doc__ == 'A composition of functions' + if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property + assert composed.__doc__ == 'A composition of functions' assert repr(composed) == 'Compose({!r}, {!r})'.format(f, h) @@ -760,9 +770,10 @@ def handler(e): assert excepting(3) == -1 assert excepting.__name__ == 'idx_excepting_ValueError' - assert 'idx docstring' in excepting.__doc__ - assert 'ValueError' in excepting.__doc__ - assert 'handler docstring' in excepting.__doc__ + if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property + assert 'idx docstring' in excepting.__doc__ + assert 'ValueError' in excepting.__doc__ + assert 'handler docstring' in excepting.__doc__ def getzero(a): """getzero docstring @@ -776,9 +787,10 @@ def getzero(a): assert excepting({0: 1}) == 1 assert excepting.__name__ == 'getzero_excepting_IndexError_or_KeyError' - assert 'getzero docstring' in excepting.__doc__ - assert 'return_none' in excepting.__doc__ - assert 'Returns None' in excepting.__doc__ + if not IS_PYPY_GE_39: # pypy >=3.9 doesn't like __doc__ property + assert 'getzero docstring' in excepting.__doc__ + assert 'return_none' in excepting.__doc__ + assert 'Returns None' in excepting.__doc__ def raise_(a): """A function that raises an instance of the exception type given. diff --git a/cytoolz/tests/test_itertoolz.py b/cytoolz/tests/test_itertoolz.py index a9d87e1..2a41487 100644 --- a/cytoolz/tests/test_itertoolz.py +++ b/cytoolz/tests/test_itertoolz.py @@ -106,9 +106,34 @@ def test_unique(): def test_isiterable(): + # objects that have a __iter__() or __getitem__() method are iterable + # https://docs.python.org/3/library/functions.html#iter + class IterIterable: + def __iter__(self): + return iter(["a", "b", "c"]) + + class GetItemIterable: + def __getitem__(self, item): + return ["a", "b", "c"][item] + + # "if a class sets __iter__() to None, the class is not iterable" + # https://docs.python.org/3/reference/datamodel.html#special-method-names + class NotIterable: + __iter__ = None + + class NotIterableEvenWithGetItem: + __iter__ = None + + def __getitem__(self, item): + return ["a", "b", "c"][item] + assert isiterable([1, 2, 3]) is True assert isiterable('abc') is True + assert isiterable(IterIterable()) is True + assert isiterable(GetItemIterable()) is True assert isiterable(5) is False + assert isiterable(NotIterable()) is False + assert isiterable(NotIterableEvenWithGetItem()) is False def test_isdistinct():