Revive for modern Python (2.0): native async, pyproject packaging, CI#754
Merged
Conversation
- Rewrite the decorator with native async/await: asyncio.coroutine was removed in Python 3.11, which made the library unusable there. Plain (non-async) handlers remain supported via inspect.iscoroutinefunction - Handlers may return a (data, status) tuple to set the response status code (closes the long-standing request in #180) - Document the handler signature (data, request) in README, answering #246 - Fix __ALL__ typo (a misnamed tuple) to a proper __all__ - Replace setup.py/setup.cfg/Makefile/tox/travis/pyup scaffolding with pyproject.toml: version 2.0 (single-sourced; the repo previously carried three conflicting versions), requires-python >=3.9, aiohttp>=3.8, jsonschema>=3.0, py.typed marker; drop the console_scripts entry point that referenced a module that never existed; remove the stale sphinx skeleton - Modernize tests for current aiohttp/pytest-aiohttp (no loop argument), add coverage for the status tuple and sync handlers - tests.yml: matrix on CPython 3.9-3.13; publish.yml: PyPI trusted publishing on v* tags or manual dispatch - README badges and examples refreshed; HISTORY updated Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQGgpBt
- inspect.iscoroutinefunction is evaluated once at decoration time instead of on every request - The (data, status) shape check excludes bools and its collision case (response data that is itself a 2-tuple ending in an int) is documented in the docstring and README - _raise_exception is annotated NoReturn so type checkers see the truth Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQGgpBt
New tests for the previously uncovered branches: the type-mismatch error formatting path, plain-class (non-web.View) method handlers, ready StreamResponse passthrough, the bool-tuple non-hijack guarantee, and tuple response data serializing as a JSON array. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQGgpBt
…ecker - A plain (non-async) handler returning an awaitable is awaited again, matching the old asyncio.coroutine behavior the async rewrite dropped - jsonschema validator instances are built once at decoration time instead of per request - New optional format_checker argument, passed through to the validator, for opt-in string format validation - HISTORY now explicitly flags the (data, status) breaking edge case - 16 tests, 100% line coverage Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQGgpBt
- Calling the handler and awaiting the result if it is awaitable covers coroutine functions and plain callables alike, so the hoisted iscoroutinefunction dispatch is gone entirely - format_checker is typed as Optional[FormatChecker] instead of Any - Validator setup uses single conditional bindings Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQMGgpBt
This was referenced Jul 19, 2026
Closed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The library has been unusable on Python 3.11+ since October 2022: the decorator is built on
@asyncio.coroutine, which was removed in 3.11, so decorating any handler raisesAttributeError. This PR brings it back to life.Core
async/await; behavior preserved, all original tests pass. Plain (non-async) handlers remain supported.(data, status)tuple to set the response status code — closes How i can return custom response status? #180.(data, request)now documented in the README — answers How to retrieve original aiohttp handler request object? #246 (the original request object was always the second argument).__ALL__typo (which was also accidentally a tuple) fixed to a proper__all__; type hints +py.typed.Packaging
setup.py/setup.cfg/Makefile/tox.ini/.travis.yml/travis_pypi_setup.py/requirements_dev.txt/MANIFEST.inand the stale sphinx skeleton replaced by a singlepyproject.toml.setup.py1.2.0,__version__0.1.1, PyPI 1.1.0).console_scriptsentry point pointing ataiohttp_validate.cli— a module that never existed, so installed scripts crashed on invocation.aiohttp>=3.8,jsonschema>=3.0,requires-python >= 3.9— addresses Outdated requirements #130.Tests / CI
loopargument), plus new coverage for the status tuple and sync handlers: 9 tests, verified locally against aiohttp 3.14.1 + jsonschema 4.26.tests.yml: CPython 3.9–3.13 matrix.publish.yml: PyPI trusted publishing onv*tags or manual dispatch (one-time PyPI setup: publisher foraiohttp_validate, workflowpublish.yml, environmentpypi).Merging this also renders the 18 open bot PRs (pyup/dependabot) obsolete — their target files no longer exist.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Ha16zNy2fDMdrZBMQGgpBt
Generated by Claude Code