Skip to content

Commit

Permalink
Add python 3.10 and drop python 3.6
Browse files Browse the repository at this point in the history
Issue #79, PR #80
  • Loading branch information
vxgmichel committed Dec 14, 2021
2 parents 871d1b1 + e377768 commit 0e8e84d
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 22 deletions.
6 changes: 1 addition & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: [3.6, 3.7, 3.8, 3.9, pypy3]
# XML coverage reporting is broken for this particular configuration
exclude:
- os: windows-latest
python-version: pypy3
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11.0-alpha.2", "pypy-3.7", "pypy-3.8"]
env:
OS: ${{ matrix.os }}
PYTHON: ${{ matrix.python-version }}
Expand Down
7 changes: 7 additions & 0 deletions aiostream/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,13 @@ def double(source):
def decorator(func):
"""Inner decorator for stream operator."""

# First check for classmethod instance, to avoid more confusing errors later on
if isinstance(func, classmethod):
raise ValueError(
"An operator cannot be created from a class method, "
"since the decorated function becomes an operator class"
)

# Gather data
bases = (Stream,)
name = func.__name__
Expand Down
16 changes: 1 addition & 15 deletions aiostream/stream/time.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,6 @@
__all__ = ["spaceout", "delay", "timeout"]


async def wait_for(aw, timeout):
task = asyncio.ensure_future(aw)
try:
return await asyncio.wait_for(task, timeout)
finally:
# Python 3.6 compatibility
if not task.done(): # pragma: no cover
task.cancel()
try:
await task
except asyncio.CancelledError:
pass


@operator(pipable=True)
async def spaceout(source, interval):
"""Make sure the elements of an asynchronous sequence are separated
Expand Down Expand Up @@ -49,7 +35,7 @@ async def timeout(source, timeout):
async with streamcontext(source) as streamer:
while True:
try:
item = await wait_for(anext(streamer), timeout)
item = await asyncio.wait_for(anext(streamer), timeout)
except StopAsyncIteration:
break
else:
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
classifiers=[
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
],
author="Vincent Michel",
author_email="vxgmichel@gmail.com",
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class B:
async def method(cls, arg):
yield 1

with pytest.raises(AttributeError):
with pytest.raises(ValueError):

class C:
@operator
Expand Down

0 comments on commit 0e8e84d

Please sign in to comment.