Skip to content

Commit

Permalink
Support Python 3.12 and update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
Cito committed Feb 10, 2024
1 parent 37f8eb2 commit d42eddb
Show file tree
Hide file tree
Showing 10 changed files with 281 additions and 132 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Install dependencies
run: |
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Set up Python 3.11
uses: actions/setup-python@v4
- name: Set up Python 3.12
uses: actions/setup-python@v5
with:
python-version: '3.11'
python-version: '3.12'

- name: Build wheel and source tarball
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:

strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', 'pypy3.9']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12', 'pypy3.9', 'pypy3.10']

steps:
- uses: actions/checkout@v3
Expand Down
276 changes: 217 additions & 59 deletions poetry.lock

Large diffs are not rendered by default.

37 changes: 24 additions & 13 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ classifiers = [
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
]
packages = [
{ include = "graphql", from = "src" },
Expand All @@ -41,41 +42,51 @@ Changelog = "https://github.com/graphql-python/graphql-core/releases"
[tool.poetry.dependencies]
python = "^3.7"
typing-extensions = [
{ version = "^4.5", python = "<3.10" }
{ version = "^4.9", python = ">=3.8,<3.10" },
{ version = "^4.7.1", python = "<3.8" },
]

[tool.poetry.group.test]
optional = true

[tool.poetry.group.test.dependencies]
pytest = "^7.3"
pytest-asyncio = ">=0.21,<1"
pytest = [
{ version = "^8.0", python = ">=3.8" },
{ version = "^7.4", python = "<3.8"}
]
pytest-asyncio = [
{ version = "^0.23.5", python = ">=3.8" },
{ version = "~0.21.1", python = "<3.8"}
]
pytest-benchmark = "^4.0"
pytest-cov = "^4.1"
pytest-describe = "^2.1"
pytest-timeout = "^2.1"
pytest-describe = "^2.2"
pytest-timeout = "^2.2"
tox = [
{ version = ">=4.12,<5", python = ">=3.8" },
{ version = ">=3.28,<4", python = "<3.8" }
{ version = "^4.12", python = ">=3.8" },
{ version = "^3.28", python = "<3.8" }
]

[tool.poetry.group.lint]
optional = true

[tool.poetry.group.lint.dependencies]
ruff = ">=0.2,<0.3"
mypy = "1.8.0"
ruff = ">=0.2.1,<0.3"
mypy = [
{ version = "^1.8", python = ">=3.8" },
{ version = "~1.4", python = "<3.8" }
]
bump2version = ">=1.0,<2"

[tool.poetry.group.doc]
optional = true

[tool.poetry.group.doc.dependencies]
sphinx = [
{ version = ">=4,<7", python = ">=3.8" },
{ version = ">=7,<8", python = ">=3.8" },
{ version = ">=4,<6", python = "<3.8" }
]
sphinx_rtd_theme = ">=1,<2"
sphinx_rtd_theme = "^2.0"

[tool.ruff]
line-length = 88
Expand Down Expand Up @@ -281,5 +292,5 @@ timeout = "100"
filterwarnings = "ignore::pytest.PytestConfigWarning"

[build-system]
requires = ["poetry_core>=1.6,<2"]
requires = ["poetry_core>=1.6.1,<2"]
build-backend = "poetry.core.masonry.api"
4 changes: 2 additions & 2 deletions src/graphql/pyutils/is_iterable.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Check whether objects are iterable"""

from array import array
from typing import Any, ByteString, Collection, Iterable, Mapping, ValuesView
from typing import Any, Collection, Iterable, Mapping, ValuesView

try:
from typing import TypeGuard
Expand All @@ -20,7 +20,7 @@
collection_types[0] if len(collection_types) == 1 else tuple(collection_types)
)
iterable_types: Any = Iterable
not_iterable_types: Any = (ByteString, Mapping, str)
not_iterable_types: Any = (bytearray, bytes, str, memoryview, Mapping)


def is_collection(value: Any) -> TypeGuard[Collection]:
Expand Down
2 changes: 1 addition & 1 deletion tests/execution/test_flatten_async_iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def nested3() -> AsyncGenerator[float, None]:

# throw error
with pytest.raises(RuntimeError, match="ouch"):
await doubles.athrow(RuntimeError, "ouch")
await doubles.athrow(RuntimeError("ouch"))

@pytest.mark.asyncio()
async def completely_yields_sub_iterables_even_when_anext_called_in_parallel():
Expand Down
32 changes: 3 additions & 29 deletions tests/execution/test_map_async_iterable.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ async def __anext__(self):
await anext(doubles)

@pytest.mark.asyncio()
async def allows_throwing_errors_with_values_through_async_iterables():
async def allows_throwing_errors_with_traceback_through_async_iterables():
class Iterable:
def __aiter__(self):
return self
Expand All @@ -163,42 +163,16 @@ async def __anext__(self):

assert await anext(one) == 2

# Throw error with value passed separately
try:
raise RuntimeError("Ouch")
except RuntimeError as error:
with pytest.raises(RuntimeError, match="Ouch") as exc_info:
await one.athrow(error.__class__, error)
await one.athrow(error)

assert exc_info.value is error # noqa: PT017
assert exc_info.tb is error.__traceback__ # noqa: PT017

with pytest.raises(StopAsyncIteration):
await anext(one)

@pytest.mark.asyncio()
async def allows_throwing_errors_with_traceback_through_async_iterables():
class Iterable:
def __aiter__(self):
return self

async def __anext__(self):
return 1

one = map_async_iterable(Iterable(), double)

assert await anext(one) == 2

# Throw error with traceback passed separately
try:
raise RuntimeError("Ouch")
except RuntimeError as error:
with pytest.raises(RuntimeError) as exc_info:
await one.athrow(error.__class__, None, error.__traceback__)

assert exc_info.tb
assert error.__traceback__ # noqa: PT017
assert exc_info.tb.tb_frame is error.__traceback__.tb_frame # noqa: PT017
assert exc_info.tb is error.__traceback__ # noqa: PT017

with pytest.raises(StopAsyncIteration):
await anext(one)
Expand Down
4 changes: 4 additions & 0 deletions tests/execution/test_stream.py
Original file line number Diff line number Diff line change
Expand Up @@ -1801,6 +1801,7 @@ async def iterable(_info):
with pytest.raises(StopAsyncIteration):
await anext(iterator)

await sleep(0)
assert finished

@pytest.mark.asyncio()
Expand Down Expand Up @@ -1850,6 +1851,8 @@ async def __anext__(self):
with pytest.raises(StopAsyncIteration):
await anext(iterator)

await sleep(0)
await sleep(0)
assert iterable.index == 4

@pytest.mark.asyncio()
Expand Down Expand Up @@ -1891,4 +1894,5 @@ async def iterable(_info):
with pytest.raises(StopAsyncIteration):
await anext(iterator)

await sleep(0)
assert finished
40 changes: 21 additions & 19 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = py3{7,8,9,10,11}, pypy39, ruff, mypy, docs
envlist = py3{7,8,9,10,11,312}, pypy{39,310}, ruff, mypy, docs
isolated_build = true

[gh-actions]
Expand All @@ -10,43 +10,45 @@ python =
3.9: py39
3.10: py310
3.11: py311
pypy3: pypy39
3.12: py312
pypy3: pypy9
pypy3.9: pypy39
pypy3.10: pypy310

[testenv:ruff]
basepython = python3.11
deps = ruff>=0.2,<0.3
basepython = python3.12
deps = ruff>=0.2.1,<0.3
commands =
ruff check src tests
ruff format --check src tests

[testenv:mypy]
basepython = python3.11
basepython = python3.12
deps =
mypy==1.8.0
pytest>=7.3,<8
mypy>=1.8.0,<1.9
pytest>=8.0,<9
commands =
mypy src tests

[testenv:docs]
basepython = python3.10
basepython = python3.12
deps =
sphinx>=5.3,<6
sphinx_rtd_theme>=1.1,<2
sphinx>=7,<8
sphinx_rtd_theme>=2.0,<3
commands =
sphinx-build -b html -nEW docs docs/_build/html

[testenv]
deps =
pytest>=7.3,<8
pytest-asyncio>=0.21,<1
pytest>=7.4,<9
pytest-asyncio>=0.21.1,<1
pytest-benchmark>=4,<5
pytest-cov>=4.1,<5
pytest-describe>=2.1,<3
pytest-timeout>=2.1,<3
py37,py38,py39,pypy39: typing-extensions>=4.5,<5
pytest-describe>=2.2,<3
pytest-timeout>=2.2,<3
py37,py38,py39,pypy39: typing-extensions>=4.7.1,<5
commands =
# to also run the time-consuming tests: tox -e py310 -- --run-slow
# to run the benchmarks: tox -e py310 -- -k benchmarks --benchmark-enable
py37,py38,py39,py311,pypy39: pytest tests {posargs}
py310: pytest tests {posargs: --cov-report=term-missing --cov=graphql --cov=tests --cov-fail-under=100}
# to also run the time-consuming tests: tox -e py311 -- --run-slow
# to run the benchmarks: tox -e py311 -- -k benchmarks --benchmark-enable
py37,py38,py39,py310,py311,pypy39,pypy310: pytest tests {posargs}
py312: pytest tests {posargs: --cov-report=term-missing --cov=graphql --cov=tests --cov-fail-under=100}

0 comments on commit d42eddb

Please sign in to comment.