Skip to content

Commit 0e623a9

Browse files
committed
Support Python 3.10
1 parent 58e67a6 commit 0e623a9

File tree

7 files changed

+30
-18
lines changed

7 files changed

+30
-18
lines changed

README.md

+1-5
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ async def main():
157157
print(result)
158158

159159

160-
loop = asyncio.get_event_loop()
161-
try:
162-
loop.run_until_complete(main())
163-
finally:
164-
loop.close()
160+
asyncio.run(main())
165161
```
166162

167163

docs/usage/queries.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Here is one way to use it::
2828
""")
2929
print(result)
3030

31-
asyncio.get_event_loop().run_until_complete(query_artoo())
31+
asyncio.run(query_artoo())
3232

3333
In our query, we asked for the droid with the id 2001, which is R2-D2, and its primary
3434
function, Astromech. When everything has been implemented correctly as shown above, you

pyproject.toml

+3-2
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ classifiers = [
2121
"Programming Language :: Python :: 3.6",
2222
"Programming Language :: Python :: 3.7",
2323
"Programming Language :: Python :: 3.8",
24-
"Programming Language :: Python :: 3.9"
24+
"Programming Language :: Python :: 3.9",
25+
"Programming Language :: Python :: 3.10"
2526
]
2627
packages = [
2728
{ include = "graphql", from = "src" },
@@ -63,7 +64,7 @@ bump2version = ">=1.0,<2"
6364
tox = "^3.24"
6465

6566
[tool.black]
66-
target-version = ['py36', 'py37', 'py38', 'py39']
67+
target-version = ['py36', 'py37', 'py38', 'py39', 'py310']
6768

6869
[build-system]
6970
requires = ["poetry_core>=1,<2"]

setup.py

+2
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,12 @@
2525
"Topic :: Software Development :: Libraries",
2626
"License :: OSI Approved :: MIT License",
2727
"Programming Language :: Python :: 3",
28+
"Programming Language :: Python :: 3 :: Only",
2829
"Programming Language :: Python :: 3.6",
2930
"Programming Language :: Python :: 3.7",
3031
"Programming Language :: Python :: 3.8",
3132
"Programming Language :: Python :: 3.9",
33+
"Programming Language :: Python :: 3.10",
3234
],
3335
install_requires=[],
3436
python_requires=">=3.6,<4",

tests/test_docs.py

+11-5
Original file line numberDiff line numberDiff line change
@@ -134,11 +134,17 @@ def executing_queries(capsys):
134134

135135
async_query = queries.pop(0)
136136
assert "asyncio" in async_query and "graphql_sync" not in async_query
137-
exec(async_query, scope)
138-
out, err = capsys.readouterr()
139-
assert not err
140-
assert "R2-D2" in out
141-
assert out == expected_result(queries)
137+
assert "asyncio.run" in async_query
138+
try: # pragma: no cover
139+
from asyncio import run # noqa: F401
140+
except ImportError: # Python < 3.7
141+
assert "ExecutionResult" in expected_result(queries)
142+
else: # pragma: no cover
143+
exec(async_query, scope)
144+
out, err = capsys.readouterr()
145+
assert not err
146+
assert "R2-D2" in out
147+
assert out == expected_result(queries)
142148

143149
sync_query = queries.pop(0)
144150
assert "graphql_sync" in sync_query and "asyncio" not in sync_query

tests/test_user_registry.py

+10-3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,11 @@
1010
from inspect import isawaitable
1111
from typing import Any, Dict, List, NamedTuple, Optional
1212

13+
try:
14+
from asyncio import create_task
15+
except ImportError: # Python < 3.7
16+
create_task = None # type: ignore
17+
1318
from pytest import fixture, mark
1419

1520
from graphql import (
@@ -504,9 +509,11 @@ async def receive_all():
504509
if len(received_all) == 6:
505510
break
506511

507-
done, pending = await wait(
508-
[mutate_users(), receive_one(), receive_all()], timeout=1
509-
)
512+
tasks = [
513+
create_task(task()) if create_task else task()
514+
for task in (mutate_users, receive_one, receive_all)
515+
]
516+
done, pending = await wait(tasks, timeout=1)
510517
assert not pending
511518

512519
expected_data: List[Dict[str, Any]] = [

tox.ini

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[tox]
2-
envlist = py{36,37,38,39}, black, flake8, mypy, docs, manifest
2+
envlist = py3{6,7,8,9}, black, flake8, mypy, docs, manifest
33
isolated_build = true
44

55
[testenv:black]
66
basepython = python3.9
77
deps = black==21.7b0
88
commands =
9-
black src tests setup.py --check
9+
black src tests setup.py -t py39 --check
1010

1111
[testenv:flake8]
1212
basepython = python3.9

0 commit comments

Comments
 (0)