From ef0ac89a76114d015eb6b2491a89a626f17773fb Mon Sep 17 00:00:00 2001 From: Christoph Zwerschke Date: Wed, 2 Nov 2022 17:56:38 +0100 Subject: [PATCH] Support Python 3.11 --- .github/workflows/lint.yml | 4 ++-- .github/workflows/publish.yml | 4 ++-- .github/workflows/test.yml | 2 +- .readthedocs.yaml | 4 ++-- docs/conf.py | 1 + pyproject.toml | 7 ++++--- tests/execution/test_nonnull.py | 3 +++ tests/pyutils/test_is_awaitable.py | 9 +++++++-- tox.ini | 15 ++++++++------- 9 files changed, 30 insertions(+), 19 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 2185a66b..fb2255e7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,10 +9,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Install dependencies run: | diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 8f2ac627..4772236c 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -12,10 +12,10 @@ jobs: steps: - uses: actions/checkout@v3 - - name: Set up Python 3.9 + - name: Set up Python 3.10 uses: actions/setup-python@v4 with: - python-version: 3.9 + python-version: 3.10 - name: Build wheel and source tarball run: | diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7210c219..8686eb1d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,7 +8,7 @@ jobs: strategy: matrix: - python: ['3.7', '3.8', '3.9', '3.10', 'pypy3.9'] + python: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.9'] steps: - uses: actions/checkout@v3 diff --git a/.readthedocs.yaml b/.readthedocs.yaml index bb8e1846..69c62c18 100644 --- a/.readthedocs.yaml +++ b/.readthedocs.yaml @@ -5,9 +5,9 @@ version: 2 build: - os: ubuntu-20.04 + os: ubuntu-22.04 tools: - python: "3.9" + python: "3.10" sphinx: configuration: docs/conf.py diff --git a/docs/conf.py b/docs/conf.py index b32115c3..f9a807c9 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -138,6 +138,7 @@ EnterLeaveVisitor FormattedSourceLocation GraphQLAbstractType +GraphQLErrorExtensions GraphQLOutputType asyncio.events.AbstractEventLoop graphql.execution.map_async_iterator.MapAsyncIterator diff --git a/pyproject.toml b/pyproject.toml index 2b11664b..4466070a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -19,7 +19,8 @@ classifiers = [ "Programming Language :: Python :: 3.7", "Programming Language :: Python :: 3.8", "Programming Language :: Python :: 3.9", - "Programming Language :: Python :: 3.10" + "Programming Language :: Python :: 3.10", + "Programming Language :: Python :: 3.11" ] packages = [ { include = "graphql", from = "src" }, @@ -80,7 +81,7 @@ sphinx_rtd_theme = ">=1,<2" exclude_dirs = ["tests"] [tool.black] -target-version = ["py37", "py38", "py39", "py310"] +target-version = ["py37", "py38", "py39", "py310", "py311"] [tool.coverage.run] branch = true @@ -119,7 +120,7 @@ force_single_line = false lines_after_imports = 2 [tool.mypy] -python_version = 3.9 +python_version = "3.10" check_untyped_defs = true no_implicit_optional = true strict_optional = true diff --git a/tests/execution/test_nonnull.py b/tests/execution/test_nonnull.py index cee46c0c..6d0f2993 100644 --- a/tests/execution/test_nonnull.py +++ b/tests/execution/test_nonnull.py @@ -1,3 +1,4 @@ +import asyncio import re from typing import Any, Awaitable, cast @@ -482,6 +483,7 @@ def describe_nulls_the_top_level_if_non_nullable_field(): @mark.asyncio async def returns_null(): result = await execute_sync_and_async(query, NullingData()) + await asyncio.sleep(0) # strangely needed to get coverage on Python 3.11 assert result == ( None, [ @@ -497,6 +499,7 @@ async def returns_null(): @mark.asyncio async def throws(): result = await execute_sync_and_async(query, ThrowingData()) + await asyncio.sleep(0) # strangely needed to get coverage on Python 3.11 assert result == ( None, [ diff --git a/tests/pyutils/test_is_awaitable.py b/tests/pyutils/test_is_awaitable.py index 896697d5..dd82a3dc 100644 --- a/tests/pyutils/test_is_awaitable.py +++ b/tests/pyutils/test_is_awaitable.py @@ -1,5 +1,6 @@ import asyncio from inspect import isawaitable +from sys import version_info as python_version from pytest import mark @@ -75,8 +76,12 @@ async def some_coroutine(): assert isawaitable(some_coroutine()) assert is_awaitable(some_coroutine()) - @mark.filterwarnings("ignore::Warning") # Deprecation and Runtime - def recognizes_an_old_style_coroutine(): + @mark.filterwarnings("ignore::Warning") # Deprecation and Runtime warnings + @mark.skipif( + python_version >= (3, 11), + reason="Generator-based coroutines not supported any more since Python 3.11", + ) + def recognizes_an_old_style_coroutine(): # pragma: no cover @asyncio.coroutine def some_old_style_coroutine(): yield False # pragma: no cover diff --git a/tox.ini b/tox.ini index 29f7de91..b2723428 100644 --- a/tox.ini +++ b/tox.ini @@ -1,5 +1,5 @@ [tox] -envlist = py3{7,8,9,10}, pypy39, black, flake8, isort, mypy, docs +envlist = py3{7,8,9,10,11}, pypy39, black, flake8, isort, mypy, docs isolated_build = true [gh-actions] @@ -8,18 +8,19 @@ python = 3.7: py37 3.8: py38 3.9: py39 - 3.10: py310 + 3.10: py310=5,<6 flake8-bandit>=4.1,<6 @@ -28,13 +29,13 @@ commands = flake8 src tests [testenv:isort] -basepython = python3.9 +basepython = python3.10 deps = isort>=5.10,<6 commands = isort src tests --check-only [testenv:mypy] -basepython = python3.9 +basepython = python3.10 deps = mypy==0.982 pytest>=7.1,<8 @@ -42,7 +43,7 @@ commands = mypy src tests [testenv:docs] -basepython = python3.9 +basepython = python3.10 deps = sphinx>=5.2.1,<6 sphinx_rtd_theme>=1,<2