diff --git a/.travis.yml b/.travis.yml index 3002df6..768f7dc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,28 @@ language: python -sudo: false -dist: trusty +dist: focal matrix: include: # These are quick and often catch errors, so list them first - - python: 3.6 + - python: 3.8 env: CHECK_DOCS=1 - - python: 3.6 + - python: 3.8 env: CHECK_FORMATTING=1 - # The pypy tests are slow, so list them early - - python: pypy3.5 + # The pypy tests are slow, so we list them first + - python: pypy3.6-7.2.0 + dist: bionic + - language: generic + env: PYPY_NIGHTLY_BRANCH=py3.6 # Uncomment if you want to test on pypy nightly: # - language: generic # env: USE_PYPY_NIGHTLY=1 - - python: 3.5.0 - - python: 3.5.2 - - python: 3.6 + - python: 3.6-dev # As of 2018-07-05, Travis's 3.7 and 3.8 builds only work if you # use dist: xenial AND sudo: required # See: https://github.com/python-trio/trio/pull/556#issuecomment-402879391 - - python: 3.7 - dist: xenial - sudo: required + - python: 3.7-dev - python: 3.8-dev - dist: xenial - sudo: required + - python: 3.9-dev script: - ci/travis.sh diff --git a/ci/rtd-requirements.in b/ci/rtd-requirements.in new file mode 100644 index 0000000..67898ba --- /dev/null +++ b/ci/rtd-requirements.in @@ -0,0 +1,4 @@ +# RTD is currently installing 1.5.3, which has a bug in :lineno-match: +sphinx >= 1.6.1 +sphinx_rtd_theme +sphinxcontrib-trio diff --git a/ci/rtd-requirements.txt b/ci/rtd-requirements.txt index 67898ba..8008227 100644 --- a/ci/rtd-requirements.txt +++ b/ci/rtd-requirements.txt @@ -1,4 +1,35 @@ -# RTD is currently installing 1.5.3, which has a bug in :lineno-match: -sphinx >= 1.6.1 -sphinx_rtd_theme -sphinxcontrib-trio +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file=rtd-requirements.txt rtd-requirements.in +# +alabaster==0.7.12 # via sphinx +babel==2.8.0 # via sphinx +certifi==2020.6.20 # via requests +chardet==3.0.4 # via requests +docutils==0.16 # via sphinx +idna==2.10 # via requests +imagesize==1.2.0 # via sphinx +jinja2==2.11.2 # via sphinx +markupsafe==1.1.1 # via jinja2 +packaging==20.4 # via sphinx +pygments==2.6.1 # via sphinx +pyparsing==2.4.7 # via packaging +pytz==2020.1 # via babel +requests==2.24.0 # via sphinx +six==1.15.0 # via packaging +snowballstemmer==2.0.0 # via sphinx +sphinx-rtd-theme==0.5.0 # via -r rtd-requirements.in +sphinx==3.2.1 # via -r rtd-requirements.in, sphinx-rtd-theme, sphinxcontrib-trio +sphinxcontrib-applehelp==1.0.2 # via sphinx +sphinxcontrib-devhelp==1.0.2 # via sphinx +sphinxcontrib-htmlhelp==1.0.3 # via sphinx +sphinxcontrib-jsmath==1.0.1 # via sphinx +sphinxcontrib-qthelp==1.0.3 # via sphinx +sphinxcontrib-serializinghtml==1.1.4 # via sphinx +sphinxcontrib-trio==1.1.2 # via -r rtd-requirements.in +urllib3==1.25.10 # via requests + +# The following packages are considered to be unsafe in a requirements file: +# setuptools diff --git a/setup.py b/setup.py index 3195c92..034e4dc 100644 --- a/setup.py +++ b/setup.py @@ -21,9 +21,11 @@ "attrs", ], keywords=[ - "async", "scheduler", "trio", + "async", + "scheduler", + "trio", ], - python_requires=">=3.5", + python_requires=">=3.6", classifiers=[ "License :: OSI Approved :: MIT License", "License :: OSI Approved :: Apache Software License", diff --git a/test-requirements.in b/test-requirements.in new file mode 100644 index 0000000..9955dec --- /dev/null +++ b/test-requirements.in @@ -0,0 +1,2 @@ +pytest +pytest-cov diff --git a/test-requirements.txt b/test-requirements.txt index 9955dec..c409c63 100644 --- a/test-requirements.txt +++ b/test-requirements.txt @@ -1,2 +1,18 @@ -pytest -pytest-cov +# +# This file is autogenerated by pip-compile +# To update, run: +# +# pip-compile --output-file=test-requirements.txt test-requirements.in +# +attrs==20.1.0 # via pytest +coverage==5.2.1 # via pytest-cov +iniconfig==1.0.1 # via pytest +more-itertools==8.5.0 # via pytest +packaging==20.4 # via pytest +pluggy==0.13.1 # via pytest +py==1.9.0 # via pytest +pyparsing==2.4.7 # via packaging +pytest-cov==2.10.1 # via -r test-requirements.in +pytest==6.0.1 # via -r test-requirements.in, pytest-cov +six==1.15.0 # via packaging +toml==0.10.1 # via pytest diff --git a/trimeter/_impl.py b/trimeter/_impl.py index 484a022..480f6ca 100644 --- a/trimeter/_impl.py +++ b/trimeter/_impl.py @@ -56,7 +56,8 @@ def new_state(self): class MaxState: def __init__(self, max_meter): self.sem = trio.Semaphore( - initial_value=max_meter.max_at_once, max_value=max_meter.max_at_once + initial_value=max_meter.max_at_once, + max_value=max_meter.max_at_once ) async def wait_task_can_start(self): @@ -73,7 +74,9 @@ def notify_task_finished(self): @attr.s(frozen=True) class TokenBucketMeter: max_per_second = attr.ib(converter=float, validator=_check_positive) - max_burst = attr.ib(default=1, converter=operator.index, validator=_check_positive) + max_burst = attr.ib( + default=1, converter=operator.index, validator=_check_positive + ) def __attrs_post_init__(self): _check_positive(self, "max_per_second", self.max_per_second) @@ -121,9 +124,7 @@ def notify_task_finished(self): # XX should we have a special-case to allow KeyboardInterrupt to pass through? -async def _worker( - async_fn, value, index, config -): +async def _worker(async_fn, value, index, config): if config.capture_outcome: result = await outcome.acapture(async_fn, value) else: @@ -203,7 +204,6 @@ async def run_on_each( await send_to.aclose() - @asynccontextmanager @async_generator async def amap( diff --git a/trimeter/_tests/conftest.py b/trimeter/_tests/conftest.py index 25c5453..e51a6a2 100644 --- a/trimeter/_tests/conftest.py +++ b/trimeter/_tests/conftest.py @@ -5,6 +5,7 @@ import pytest from trio.testing import MockClock, trio_test + @pytest.fixture def mock_clock(): return MockClock() diff --git a/trimeter/_tests/test_basics.py b/trimeter/_tests/test_basics.py index af6caba..7fd470c 100644 --- a/trimeter/_tests/test_basics.py +++ b/trimeter/_tests/test_basics.py @@ -2,6 +2,7 @@ import trio from trimeter import run_on_each, amap, run_all + # Just the most basic smoke test of the three functions async def test_basics(): ran_on = [] @@ -20,9 +21,11 @@ async def afn(value): results.append(result) assert sorted(results) == [2, 3, 4] - results = await run_all([ - partial(afn, 10), - partial(afn, 11), - partial(afn, 12), - ]) + results = await run_all( + [ + partial(afn, 10), + partial(afn, 11), + partial(afn, 12), + ] + ) assert results == [11, 12, 13]