Skip to content

Commit

Permalink
chore: update to latest versions of framework (#120)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
kiendang authored Oct 13, 2023
1 parent a95e12f commit 17363af
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Build wheel and source tarball
run: |
pip install wheel
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Install dependencies
run: |
python -m pip install --upgrade pip
Expand Down
8 changes: 2 additions & 6 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ jobs:
strategy:
max-parallel: 4
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
os: [ubuntu-latest, windows-latest]
exclude:
- os: windows-latest
python-version: "3.7"
- os: windows-latest
python-version: "3.8"
- os: windows-latest
Expand All @@ -32,8 +30,6 @@ jobs:
pip install tox tox-gh-actions
- name: Test with tox
run: tox
env:
TOXENV: ${{ matrix.toxenv }}

coverage:
runs-on: ubuntu-latest
Expand All @@ -43,7 +39,7 @@ jobs:
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
python-version: "3.11"
- name: Install test dependencies
run: |
python -m pip install --upgrade pip
Expand Down
4 changes: 2 additions & 2 deletions graphql_server/sanic/graphqlview.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import asyncio
import copy
from cgi import parse_header
from collections.abc import MutableMapping
from functools import partial
from typing import List

from graphql import GraphQLError, specified_rules
from graphql.pyutils import is_awaitable
from graphql.type.schema import GraphQLSchema
from sanic.headers import parse_content_header
from sanic.response import HTTPResponse, html
from sanic.views import HTTPMethodView

Expand Down Expand Up @@ -213,7 +213,7 @@ def get_mime_type(request):
if "content-type" not in request.headers:
return None

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

def should_display_graphiql(self, request):
Expand Down
15 changes: 7 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,23 @@
"pytest-asyncio>=0.20,<1",
"pytest-cov>=4,<5",
"Jinja2>=3.1,<4",
"sanic-testing>=22.3,<23",
"sanic-testing>=22.3,<24",
]

dev_requires = [
"flake8>=5,<6",
"flake8>=6,<7",
"isort>=5,<6",
"black>=22.12,<22.13",
"mypy>=0.991,<1",
"black>=23.9,<23.10",
"mypy>=1.6,<1.7",
"check-manifest>=0.47,<1",
] + tests_requires

install_flask_requires = [
"flask>=1,<3",
"flask>=1,<4",
]

install_sanic_requires = [
"sanic>=21.12,<23",
"sanic>=21.12,<24",
]

install_webob_requires = [
Expand Down Expand Up @@ -71,11 +71,10 @@
"Development Status :: 3 - Alpha",
"Intended Audience :: Developers",
"Topic :: Software Development :: Libraries",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"License :: OSI Approved :: MIT License",
],
keywords="api graphql protocol rest",
Expand Down
19 changes: 16 additions & 3 deletions tests/flask/test_graphqlview.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import json
from io import StringIO
from urllib.parse import urlencode

import pytest
Expand Down Expand Up @@ -518,10 +517,24 @@ def test_allow_empty_custom_context(app, client):

def test_post_multipart_data(app, client):
query = "mutation TestMutation { writeTest { test } }"

data = (
"------flaskgraphql\r\n"
'Content-Disposition: form-data; name="query"\r\n'
"\r\n" + query + "\r\n"
"------flaskgraphql--\r\n"
"Content-Type: text/plain; charset=utf-8\r\n"
'Content-Disposition: form-data; name="file"; filename="text1.txt";'
" filename*=utf-8''text1.txt\r\n"
"\r\n"
"\r\n"
"------flaskgraphql--\r\n"
)

response = client.post(
url_string(app),
data={"query": query, "file": (StringIO(), "text1.txt")},
content_type="multipart/form-data",
data=data,
content_type="multipart/form-data; boundary=----flaskgraphql",
)

assert response.status_code == 200
Expand Down
17 changes: 8 additions & 9 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
[tox]
envlist =
black,flake8,import-order,mypy,manifest,
py{37,38,39,310,311}
py{38,39,310,311}
; requires = tox-conda

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
Expand All @@ -23,35 +22,35 @@ whitelist_externals =
python
commands =
pip install -U setuptools
py{37,38,39,311}: pytest tests {posargs}
py{310}: pytest tests --cov-report=term-missing --cov=graphql_server {posargs}
py{38,39,310}: pytest tests {posargs}
py{311}: pytest tests --cov-report=term-missing --cov=graphql_server {posargs}

[testenv:black]
basepython = python3.10
basepython = python3.11
deps = -e.[dev]
commands =
black --check graphql_server tests

[testenv:flake8]
basepython = python3.10
basepython = python3.11
deps = -e.[dev]
commands =
flake8 setup.py graphql_server tests

[testenv:import-order]
basepython = python3.10
basepython = python3.11
deps = -e.[dev]
commands =
isort graphql_server/ tests/

[testenv:mypy]
basepython = python3.10
basepython = python3.11
deps = -e.[dev]
commands =
mypy graphql_server tests --ignore-missing-imports

[testenv:manifest]
basepython = python3.10
basepython = python3.11
deps = -e.[dev]
commands =
check-manifest -v

0 comments on commit 17363af

Please sign in to comment.