Skip to content

Commit

Permalink
Merge branch '4.0-dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
agronholm committed Oct 1, 2022
2 parents 19a962c + 195b1cd commit 9f97cd7
Show file tree
Hide file tree
Showing 41 changed files with 1,697 additions and 1,919 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: test suite

on:
push:
branches: [master]
branches: [master, 4.0-dev]
pull_request:

jobs:
Expand All @@ -28,24 +28,24 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10", pypy-3.7]
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11-dev", pypy-3.8]
exclude:
- os: macos-latest
python-version: "3.7"
- os: macos-latest
python-version: "3.8"
- os: macos-latest
python-version: "3.9"
- os: macos-latest
python-version: pypy-3.7
- os: windows-latest
python-version: "3.7"
python-version: "3.11-dev"
- os: macos-latest
python-version: pypy-3.8
- os: windows-latest
python-version: "3.8"
- os: windows-latest
python-version: "3.9"
- os: windows-latest
python-version: pypy-3.7 # https://github.com/python-trio/trio/issues/1361
python-version: "3.11-dev"
- os: windows-latest
python-version: pypy-3.8 # https://github.com/python-trio/trio/issues/1361
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v2
Expand All @@ -58,11 +58,17 @@ jobs:
path: ~/.cache/pip
key: pip-test-${{ matrix.python-version }}-${{ matrix.os }}
- name: Install dependencies
run: pip install .[test,trio] coveralls
run: pip install .[test] coveralls
- name: Test with pytest
run: coverage run -m pytest
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: 1
if: ${{ matrix.python-version != '3.11-dev' }}
- name: Test with pytest
run: pytest
env:
PYTEST_DISABLE_PLUGIN_AUTOLOAD: 1
if: ${{ matrix.python-version == '3.11-dev' }}
- name: Upload Coverage
run: coveralls --service=github
env:
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ repos:
- id: pyproject-flake8

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v0.971
rev: v0.981
hooks:
- id: mypy
additional_dependencies: [ "pytest", "trio-typing", "packaging" ]
Expand Down
4 changes: 2 additions & 2 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ If you wish to contribute a fix or feature to AnyIO, please follow the following
When you make a pull request against the main AnyIO codebase, Github runs the AnyIO test suite
against your modified code. Before making a pull request, you should ensure that the modified code
passes tests locally. To that end, the use of tox_ is recommended. The default tox run first runs
code style fixing tools and then the actual test suite. To only run the code style fixers, run
``tox -e lint``. To run the checks on all environments in parallel, invoke tox with ``tox -p``.
``pre-commit`` and then the actual test suite. To run the checks on all environments in parallel,
invoke tox with ``tox -p``.

To build the documentation, run ``tox -e docs`` which will generate a directory named ``build``
in which you may view the formatted HTML documentation.
Expand Down
44 changes: 41 additions & 3 deletions docs/tasks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,47 @@ It is possible for more than one task to raise an exception in a task group. Thi
a task reacts to cancellation by entering either an exception handler block or a ``finally:``
block and raises an exception there. This raises the question: which exception is propagated from
the task group context manager? The answer is "both". In practice this means that a special
exception, :exc:`~ExceptionGroup` is raised which contains both exception objects.
Unfortunately this complicates any code that wishes to catch a specific exception because it could
be wrapped in an :exc:`~ExceptionGroup`.
exception, :exc:`ExceptionGroup` (or :exc:`BaseExceptionGroup`) is raised which contains both
exception objects.

To catch such exceptions potentially nested in groups, special measures are required.
On Python 3.11 and later, you can use the ``except*`` syntax to catch multiple exceptions::

try:
async with TaskGroup() as tg:
tg.start_soon(some_task)
tg.start_soon(another_task)
except* ValueError:
... # handle each ValueError
except* KeyError:
... # handle each KeyError

If compatibility with older Python versions is required, you can use the ``catch()`` function from
the exceptiongroup_ package::

from exceptiongroup import catch

def handle_valueerror(exc: ValueError) -> None:
... # handle each ValueError

def handle_keyerror(exc: KeyError) -> None:
... # handle each KeyError

with catch({
ValueError: handle_valueerror,
KeyError: handle_keyerror
}):
async with TaskGroup() as tg:
tg.start_soon(some_task)
tg.start_soon(another_task)

If you need to set local variables in the handlers, declare them as ``nonlocal``::

def handle_valueerror(exc):
nonlocal somevariable
somevariable = 'whatever'

.. _exceptiongroup:: https://pypi.org/project/exceptiongroup/

Context propagation
-------------------
Expand Down
5 changes: 4 additions & 1 deletion docs/versionhistory.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ This library adheres to `Semantic Versioning 2.0 <http:https://semver.org/>`_.

**UNRELEASED**

- **BACKWARDS INCOMPATIBLE** Replaced AnyIO's own ``ExceptionGroup`` class with the PEP
654 ``BaseExceptionGroup`` and ``ExceptionGroup``
- Bumped minimum version of trio to v0.22
- Added ``create_unix_datagram_socket`` and ``create_connected_unix_datagram_socket`` to
create UNIX datagram sockets (PR by Jean Hominal)
- Fixed ``ConcurrencyLimiter`` on the asyncio backend to order waiting tasks in the FIFO
- Fixed ``CapacityLimiter`` on the asyncio backend to order waiting tasks in the FIFO
order (instead of LIFO) (PR by Conor Stevenson)

**3.6.1**
Expand Down
97 changes: 92 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,11 +1,64 @@
[build-system]
requires = [
"setuptools >= 42",
"wheel >= 0.29.0",
"setuptools_scm[toml] >= 3.4"
"setuptools >= 61",
"setuptools_scm >= 6.4"
]
build-backend = "setuptools.build_meta"

[project]
name = "anyio"
description = "High level compatibility layer for multiple asynchronous event loop implementations"
readme = "README.rst"
authors = [{name = "Alex Grönholm", email = "[email protected]"}]
license = {text = "MIT"}
classifiers = [
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Framework :: AnyIO",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
]
requires-python = ">= 3.7"
dependencies = [
"exceptiongroup; python_version < '3.11'",
"idna >= 2.8",
"sniffio >= 1.1",
"typing_extensions; python_version < '3.8'",
]
dynamic = ["version"]

[project.urls]
Documentation = "https://anyio.readthedocs.io/en/latest/"
"Source code" = "https://github.com/agronholm/anyio"
"Issue tracker" = "https://github.com/agronholm/anyio/issues"

[project.optional-dependencies]
trio = ["trio >= 0.22"]
test = [
"trio >= 0.22",
"mock >= 4; python_version < '3.8'",
"coverage[toml] >= 4.5",
"hypothesis >= 4.0",
"pytest >= 7.0",
"pytest-mock >= 3.6.1",
"trustme",
"uvloop >= 0.15; platform_python_implementation == 'CPython' and platform_system != 'Windows' and python_version < '3.11'",
]
doc = [
"packaging",
"sphinx_rtd_theme",
"sphinx-autodoc-typehints >= 1.2.0",
]

[project.entry-points]
pytest11 = {anyio = "anyio.pytest_plugin"}

[tool.setuptools_scm]
version_scheme = "post-release"
local_scheme = "dirty-tag"
Expand All @@ -19,7 +72,7 @@ max-line-length = 99
ignore = ["E203", "W503"]

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
strict = true
ignore_missing_imports = true
disallow_any_generics = false
Expand All @@ -29,7 +82,7 @@ disallow_subclassing_any = false
show_error_codes = true

[tool.pytest.ini_options]
addopts = "-rsx --tb=short --strict-config --strict-markers -p anyio -p no:asyncio"
addopts = "-rsx --tb=short --strict-config --strict-markers -p anyio -p no:asyncio -p no:trio"
testpaths = ["tests"]
# Ignore resource warnings due to a CPython/Windows bug (https://bugs.python.org/issue44428)
filterwarnings = [
Expand All @@ -50,3 +103,37 @@ relative_files = true

[tool.coverage.report]
show_missing = true

[tool.tox]
legacy_tox_ini = """
[tox]
minversion = 3.7.0
envlist = pre-commit, py37, py38, py39, py310, py311, pypy3
skip_missing_interpreters = true
isolated_build = true
[testenv]
depends = pre-commit
commands = coverage run -m pytest {posargs}
extras = test
[testenv:py311]
commands = pytest {posargs}
[testenv:pre-commit]
depends =
basepython = python3
deps = pre-commit
commands = pre-commit run --all-files --show-diff-on-failure
skip_install = true
[testenv:pyright]
deps = pyright
commands = pyright --verifytypes anyio
usedevelop = true
[testenv:docs]
depends =
extras = doc
commands = sphinx-build docs build/sphinx
"""
64 changes: 1 addition & 63 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -1,63 +1 @@
[metadata]
name = anyio
description = High level compatibility layer for multiple asynchronous event loop implementations
long_description = file: README.rst
author = Alex Grönholm
author_email = [email protected]
project_urls =
Documentation = https://anyio.readthedocs.io/en/latest/
Source code = https://github.com/agronholm/anyio
Issue tracker = https://github.com/agronholm/anyio/issues
license = MIT
classifiers =
Development Status :: 5 - Production/Stable
Intended Audience :: Developers
License :: OSI Approved :: MIT License
Framework :: AnyIO
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

[options]
package_dir=
= src
packages = find:
python_requires = >= 3.6.2
zip_safe = False
install_requires =
contextvars; python_version < '3.7'
dataclasses; python_version < '3.7'
idna >= 2.8
sniffio >= 1.1
typing_extensions; python_version < '3.8'

[options.packages.find]
where = src

[options.package_data]
anyio = py.typed

[options.extras_require]
test =
mock >= 4; python_version < '3.8'
contextlib2; python_version < '3.7'
coverage[toml] >= 4.5
hypothesis >= 4.0
pytest >= 7.0
pytest-mock >= 3.6.1
trustme
uvloop < 0.15; python_version < '3.7' and (platform_python_implementation == 'CPython' and platform_system != 'Windows')
uvloop >= 0.15; python_version >= '3.7' and (platform_python_implementation == 'CPython' and platform_system != 'Windows')
trio = trio >= 0.16
doc =
packaging
sphinx_rtd_theme
sphinx-autodoc-typehints >= 1.2.0

[options.entry_points]
pytest11 =
anyio = anyio.pytest_plugin
# Should be deleted when setuptools gets PEP 660 support
3 changes: 0 additions & 3 deletions setup.py

This file was deleted.

Loading

0 comments on commit 9f97cd7

Please sign in to comment.