Skip to content

Commit ec4ed15

Browse files
committed
Support Python 3.10
Also restrict web frameworks to supported versions
1 parent bda6a87 commit ec4ed15

File tree

15 files changed

+61
-47
lines changed

15 files changed

+61
-47
lines changed

.github/workflows/deploy.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ jobs:
1111

1212
steps:
1313
- uses: actions/checkout@v2
14-
- name: Set up Python 3.8
14+
- name: Set up Python 3.9
1515
uses: actions/setup-python@v2
1616
with:
17-
python-version: 3.8
17+
python-version: 3.9
1818
- name: Build wheel and source tarball
1919
run: |
2020
pip install wheel
@@ -23,4 +23,4 @@ jobs:
2323
uses: pypa/[email protected]
2424
with:
2525
user: __token__
26-
password: ${{ secrets.pypi_password }}
26+
password: ${{ secrets.pypi_password }}

.github/workflows/lint.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ jobs:
88

99
steps:
1010
- uses: actions/checkout@v2
11-
- name: Set up Python 3.8
11+
- name: Set up Python 3.9
1212
uses: actions/setup-python@v2
1313
with:
14-
python-version: 3.8
14+
python-version: 3.9
1515
- name: Install dependencies
1616
run: |
1717
python -m pip install --upgrade pip
1818
pip install tox
1919
- name: Run lint and static type checks
2020
run: tox
2121
env:
22-
TOXENV: flake8,black,import-order,mypy,manifest
22+
TOXENV: flake8,black,import-order,mypy,manifest

.github/workflows/tests.yml

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,17 @@ jobs:
88
strategy:
99
max-parallel: 4
1010
matrix:
11-
python-version: ["3.6", "3.7", "3.8", "3.9"]
11+
python-version: ["3.6", "3.7", "3.8", "3.9", "3.10"]
1212
os: [ubuntu-latest, windows-latest]
1313
exclude:
1414
- os: windows-latest
1515
python-version: "3.6"
1616
- os: windows-latest
1717
python-version: "3.7"
1818
- os: windows-latest
19-
python-version: "3.9"
19+
python-version: "3.8"
20+
- os: windows-latest
21+
python-version: "3.10"
2022

2123
steps:
2224
- uses: actions/checkout@v2
@@ -38,10 +40,10 @@ jobs:
3840

3941
steps:
4042
- uses: actions/checkout@v2
41-
- name: Set up Python 3.8
43+
- name: Set up Python 3.9
4244
uses: actions/setup-python@v2
4345
with:
44-
python-version: 3.8
46+
python-version: 3.9
4547
- name: Install test dependencies
4648
run: |
4749
python -m pip install --upgrade pip

graphql_server/__init__.py

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,17 @@
99
import json
1010
from collections import namedtuple
1111
from collections.abc import MutableMapping
12-
from typing import Any, Callable, Collection, Dict, List, Optional, Type, Union
12+
from typing import (
13+
Any,
14+
Callable,
15+
Collection,
16+
Dict,
17+
List,
18+
Optional,
19+
Type,
20+
Union,
21+
cast,
22+
)
1323

1424
from graphql.error import GraphQLError
1525
from graphql.execution import ExecutionResult, execute
@@ -56,7 +66,7 @@
5666

5767
def format_error_default(error: GraphQLError) -> Dict:
5868
"""The default function for converting GraphQLError to a dictionary."""
59-
return error.formatted
69+
return cast(Dict, error.formatted)
6070

6171

6272
def run_http_query(

graphql_server/aiohttp/graphqlview.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,9 @@ async def __call__(self, request):
201201
return web.Response(text=source, content_type="text/html")
202202

203203
return web.Response(
204-
text=result, status=status_code, content_type="application/json",
204+
text=result,
205+
status=status_code,
206+
content_type="application/json",
205207
)
206208

207209
except HttpQueryError as err:

graphql_server/flask/graphqlview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
from flask import Response, render_template_string, request
77
from flask.views import View
8+
from graphql import specified_rules
89
from graphql.error import GraphQLError
910
from graphql.type.schema import GraphQLSchema
10-
from graphql import specified_rules
1111

1212
from graphql_server import (
1313
GraphQLParams,

graphql_server/sanic/graphqlview.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,8 @@ def request_wants_html(request):
212212
return "text/html" in accept or "*/*" in accept
213213

214214
def process_preflight(self, request):
215-
""" Preflight request support for apollo-client
216-
https://www.w3.org/TR/cors/#resource-preflight-requests """
215+
"""Preflight request support for apollo-client
216+
https://www.w3.org/TR/cors/#resource-preflight-requests"""
217217
origin = request.headers.get("Origin", "")
218218
method = request.headers.get("Access-Control-Request-Method", "").upper()
219219

graphql_server/webob/graphqlview.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33
from functools import partial
44
from typing import List
55

6+
from graphql import specified_rules
67
from graphql.error import GraphQLError
78
from graphql.type.schema import GraphQLSchema
8-
from graphql import specified_rules
99
from webob import Response
1010

1111
from graphql_server import (

setup.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
]
2525

2626
install_sanic_requires = [
27-
"sanic>=21,<22",
27+
"sanic>=20.3,<21",
2828
]
2929

3030
install_webob_requires = [
@@ -35,7 +35,7 @@
3535
"aiohttp>=3.8,<4",
3636
]
3737

38-
install_quart_requires = ["quart>=0.6.15,<1"]
38+
install_quart_requires = ["quart>=0.6.15,<0.15"]
3939

4040
install_all_requires = (
4141
install_requires
@@ -71,6 +71,7 @@
7171
"Programming Language :: Python :: 3.7",
7272
"Programming Language :: Python :: 3.8",
7373
"Programming Language :: Python :: 3.9",
74+
"Programming Language :: Python :: 3.10",
7475
"License :: OSI Approved :: MIT License",
7576
],
7677
keywords="api graphql protocol rest",

tests/aiohttp/schema.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ def resolve_raises(*_):
1818
QueryRootType = GraphQLObjectType(
1919
name="QueryRoot",
2020
fields={
21-
"thrower": GraphQLField(GraphQLNonNull(GraphQLString), resolve=resolve_raises,),
21+
"thrower": GraphQLField(
22+
GraphQLNonNull(GraphQLString),
23+
resolve=resolve_raises,
24+
),
2225
"request": GraphQLField(
2326
GraphQLNonNull(GraphQLString),
2427
resolve=lambda obj, info, *args: info.context["request"].query.get("q"),

tests/aiohttp/test_graphiqlview.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ async def test_graphiql_is_enabled(app, client):
5252
@pytest.mark.parametrize("app", [create_app(graphiql=True)])
5353
async def test_graphiql_simple_renderer(app, client, pretty_response):
5454
response = await client.get(
55-
url_string(query="{test}"), headers={"Accept": "text/html"},
55+
url_string(query="{test}"),
56+
headers={"Accept": "text/html"},
5657
)
5758
assert response.status == 200
5859
assert pretty_response in await response.text()
@@ -65,15 +66,19 @@ class TestJinjaEnv:
6566
)
6667
async def test_graphiql_jinja_renderer_async(self, app, client, pretty_response):
6768
response = await client.get(
68-
url_string(query="{test}"), headers={"Accept": "text/html"},
69+
url_string(query="{test}"),
70+
headers={"Accept": "text/html"},
6971
)
7072
assert response.status == 200
7173
assert pretty_response in await response.text()
7274

7375

7476
@pytest.mark.asyncio
7577
async def test_graphiql_html_is_not_accepted(client):
76-
response = await client.get("/graphql", headers={"Accept": "application/json"},)
78+
response = await client.get(
79+
"/graphql",
80+
headers={"Accept": "application/json"},
81+
)
7782
assert response.status == 400
7883

7984

@@ -107,7 +112,8 @@ async def test_graphiql_get_subscriptions(app, client):
107112
)
108113
async def test_graphiql_enabled_async_schema(app, client):
109114
response = await client.get(
110-
url_string(query="{a,b,c}"), headers={"Accept": "text/html"},
115+
url_string(query="{a,b,c}"),
116+
headers={"Accept": "text/html"},
111117
)
112118

113119
expected_response = (
@@ -133,7 +139,8 @@ async def test_graphiql_enabled_async_schema(app, client):
133139
)
134140
async def test_graphiql_enabled_sync_schema(app, client):
135141
response = await client.get(
136-
url_string(query="{a,b}"), headers={"Accept": "text/html"},
142+
url_string(query="{a,b}"),
143+
headers={"Accept": "text/html"},
137144
)
138145

139146
expected_response = (

tests/quart/test_graphiqlview.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
import sys
2-
31
import pytest
42
from quart import Quart, Response, url_for
53
from quart.testing import QuartClient
@@ -32,10 +30,7 @@ async def execute_client(
3230
headers: Headers = None,
3331
**extra_params
3432
) -> Response:
35-
if sys.version_info >= (3, 7):
36-
test_request_context = app.test_request_context("/", method=method)
37-
else:
38-
test_request_context = app.test_request_context(method, "/")
33+
test_request_context = app.test_request_context(path="/", method=method)
3934
async with test_request_context:
4035
string = url_for("graphql", **extra_params)
4136
return await client.get(string, headers=headers)

tests/quart/test_graphqlview.py

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,4 @@
11
import json
2-
import sys
3-
4-
# from io import StringIO
52
from urllib.parse import urlencode
63

74
import pytest
@@ -37,10 +34,7 @@ async def execute_client(
3734
headers: Headers = None,
3835
**url_params,
3936
) -> Response:
40-
if sys.version_info >= (3, 7):
41-
test_request_context = app.test_request_context("/", method=method)
42-
else:
43-
test_request_context = app.test_request_context(method, "/")
37+
test_request_context = app.test_request_context(path="/", method=method)
4438
async with test_request_context:
4539
string = url_for("graphql")
4640

tests/sanic/app.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
from .schema import Schema
99

10-
1110
Sanic.test_mode = True
1211

1312

tox.ini

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[tox]
2-
envlist =
2+
envlist =
33
black,flake8,import-order,mypy,manifest,
4-
py{36,37,38,39}
4+
py{36,37,38,39,310}
55
; requires = tox-conda
66

77
[gh-actions]
@@ -10,6 +10,7 @@ python =
1010
3.7: py37
1111
3.8: py38
1212
3.9: py39
13+
3.10: py310
1314

1415
[testenv]
1516
conda_channels = conda-forge
@@ -26,31 +27,31 @@ commands =
2627
py{38}: pytest tests --cov-report=term-missing --cov=graphql_server {posargs}
2728

2829
[testenv:black]
29-
basepython = python3.8
30+
basepython = python3.9
3031
deps = -e.[dev]
3132
commands =
3233
black --check graphql_server tests
3334

3435
[testenv:flake8]
35-
basepython = python3.8
36+
basepython = python3.9
3637
deps = -e.[dev]
3738
commands =
3839
flake8 setup.py graphql_server tests
3940

4041
[testenv:import-order]
41-
basepython = python3.8
42+
basepython = python3.9
4243
deps = -e.[dev]
4344
commands =
44-
isort -rc graphql_server/ tests/
45+
isort graphql_server/ tests/
4546

4647
[testenv:mypy]
47-
basepython = python3.8
48+
basepython = python3.9
4849
deps = -e.[dev]
4950
commands =
5051
mypy graphql_server tests --ignore-missing-imports
5152

5253
[testenv:manifest]
53-
basepython = python3.8
54+
basepython = python3.9
5455
deps = -e.[dev]
5556
commands =
5657
check-manifest -v

0 commit comments

Comments
 (0)