Skip to content

Commit 17363af

Browse files
authored
chore: update to latest versions of framework (#120)
* chore: update to flask 3 * chore: update to sanic 23 * fix: remove use of deprecated cgi module * chore: remove Python 3.7 from CI EOL since 2023-06-27 https://devguide.python.org/versions/ * chore: remove unused context * chore: update versions of dev tools * chore: make 3.11 the default python version in CI
1 parent a95e12f commit 17363af

File tree

7 files changed

+37
-30
lines changed

7 files changed

+37
-30
lines changed

.github/workflows/deploy.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
- name: Set up Python
1515
uses: actions/setup-python@v4
1616
with:
17-
python-version: "3.10"
17+
python-version: "3.11"
1818
- name: Build wheel and source tarball
1919
run: |
2020
pip install wheel

.github/workflows/lint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ jobs:
1111
- name: Set up Python
1212
uses: actions/setup-python@v4
1313
with:
14-
python-version: "3.10"
14+
python-version: "3.11"
1515
- name: Install dependencies
1616
run: |
1717
python -m pip install --upgrade pip

.github/workflows/tests.yml

+2-6
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ jobs:
88
strategy:
99
max-parallel: 4
1010
matrix:
11-
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
11+
python-version: ["3.8", "3.9", "3.10", "3.11"]
1212
os: [ubuntu-latest, windows-latest]
1313
exclude:
14-
- os: windows-latest
15-
python-version: "3.7"
1614
- os: windows-latest
1715
python-version: "3.8"
1816
- os: windows-latest
@@ -32,8 +30,6 @@ jobs:
3230
pip install tox tox-gh-actions
3331
- name: Test with tox
3432
run: tox
35-
env:
36-
TOXENV: ${{ matrix.toxenv }}
3733

3834
coverage:
3935
runs-on: ubuntu-latest
@@ -43,7 +39,7 @@ jobs:
4339
- name: Set up Python
4440
uses: actions/setup-python@v4
4541
with:
46-
python-version: "3.10"
42+
python-version: "3.11"
4743
- name: Install test dependencies
4844
run: |
4945
python -m pip install --upgrade pip

graphql_server/sanic/graphqlview.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import asyncio
22
import copy
3-
from cgi import parse_header
43
from collections.abc import MutableMapping
54
from functools import partial
65
from typing import List
76

87
from graphql import GraphQLError, specified_rules
98
from graphql.pyutils import is_awaitable
109
from graphql.type.schema import GraphQLSchema
10+
from sanic.headers import parse_content_header
1111
from sanic.response import HTTPResponse, html
1212
from sanic.views import HTTPMethodView
1313

@@ -213,7 +213,7 @@ def get_mime_type(request):
213213
if "content-type" not in request.headers:
214214
return None
215215

216-
mime_type, _ = parse_header(request.headers["content-type"])
216+
mime_type, _ = parse_content_header(request.headers["content-type"])
217217
return mime_type
218218

219219
def should_display_graphiql(self, request):

setup.py

+7-8
Original file line numberDiff line numberDiff line change
@@ -12,23 +12,23 @@
1212
"pytest-asyncio>=0.20,<1",
1313
"pytest-cov>=4,<5",
1414
"Jinja2>=3.1,<4",
15-
"sanic-testing>=22.3,<23",
15+
"sanic-testing>=22.3,<24",
1616
]
1717

1818
dev_requires = [
19-
"flake8>=5,<6",
19+
"flake8>=6,<7",
2020
"isort>=5,<6",
21-
"black>=22.12,<22.13",
22-
"mypy>=0.991,<1",
21+
"black>=23.9,<23.10",
22+
"mypy>=1.6,<1.7",
2323
"check-manifest>=0.47,<1",
2424
] + tests_requires
2525

2626
install_flask_requires = [
27-
"flask>=1,<3",
27+
"flask>=1,<4",
2828
]
2929

3030
install_sanic_requires = [
31-
"sanic>=21.12,<23",
31+
"sanic>=21.12,<24",
3232
]
3333

3434
install_webob_requires = [
@@ -71,11 +71,10 @@
7171
"Development Status :: 3 - Alpha",
7272
"Intended Audience :: Developers",
7373
"Topic :: Software Development :: Libraries",
74-
"Programming Language :: Python :: 3.6",
75-
"Programming Language :: Python :: 3.7",
7674
"Programming Language :: Python :: 3.8",
7775
"Programming Language :: Python :: 3.9",
7876
"Programming Language :: Python :: 3.10",
77+
"Programming Language :: Python :: 3.11",
7978
"License :: OSI Approved :: MIT License",
8079
],
8180
keywords="api graphql protocol rest",

tests/flask/test_graphqlview.py

+16-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import json
2-
from io import StringIO
32
from urllib.parse import urlencode
43

54
import pytest
@@ -518,10 +517,24 @@ def test_allow_empty_custom_context(app, client):
518517

519518
def test_post_multipart_data(app, client):
520519
query = "mutation TestMutation { writeTest { test } }"
520+
521+
data = (
522+
"------flaskgraphql\r\n"
523+
'Content-Disposition: form-data; name="query"\r\n'
524+
"\r\n" + query + "\r\n"
525+
"------flaskgraphql--\r\n"
526+
"Content-Type: text/plain; charset=utf-8\r\n"
527+
'Content-Disposition: form-data; name="file"; filename="text1.txt";'
528+
" filename*=utf-8''text1.txt\r\n"
529+
"\r\n"
530+
"\r\n"
531+
"------flaskgraphql--\r\n"
532+
)
533+
521534
response = client.post(
522535
url_string(app),
523-
data={"query": query, "file": (StringIO(), "text1.txt")},
524-
content_type="multipart/form-data",
536+
data=data,
537+
content_type="multipart/form-data; boundary=----flaskgraphql",
525538
)
526539

527540
assert response.status_code == 200

tox.ini

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
[tox]
22
envlist =
33
black,flake8,import-order,mypy,manifest,
4-
py{37,38,39,310,311}
4+
py{38,39,310,311}
55
; requires = tox-conda
66

77
[gh-actions]
88
python =
9-
3.7: py37
109
3.8: py38
1110
3.9: py39
1211
3.10: py310
@@ -23,35 +22,35 @@ whitelist_externals =
2322
python
2423
commands =
2524
pip install -U setuptools
26-
py{37,38,39,311}: pytest tests {posargs}
27-
py{310}: pytest tests --cov-report=term-missing --cov=graphql_server {posargs}
25+
py{38,39,310}: pytest tests {posargs}
26+
py{311}: pytest tests --cov-report=term-missing --cov=graphql_server {posargs}
2827

2928
[testenv:black]
30-
basepython = python3.10
29+
basepython = python3.11
3130
deps = -e.[dev]
3231
commands =
3332
black --check graphql_server tests
3433

3534
[testenv:flake8]
36-
basepython = python3.10
35+
basepython = python3.11
3736
deps = -e.[dev]
3837
commands =
3938
flake8 setup.py graphql_server tests
4039

4140
[testenv:import-order]
42-
basepython = python3.10
41+
basepython = python3.11
4342
deps = -e.[dev]
4443
commands =
4544
isort graphql_server/ tests/
4645

4746
[testenv:mypy]
48-
basepython = python3.10
47+
basepython = python3.11
4948
deps = -e.[dev]
5049
commands =
5150
mypy graphql_server tests --ignore-missing-imports
5251

5352
[testenv:manifest]
54-
basepython = python3.10
53+
basepython = python3.11
5554
deps = -e.[dev]
5655
commands =
5756
check-manifest -v

0 commit comments

Comments
 (0)