diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 271642c..454da04 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 454ab1b..0f7453c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -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 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 7e58bb5..ceecb95 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -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 @@ -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 @@ -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 diff --git a/graphql_server/sanic/graphqlview.py b/graphql_server/sanic/graphqlview.py index e8af82d..50e9922 100644 --- a/graphql_server/sanic/graphqlview.py +++ b/graphql_server/sanic/graphqlview.py @@ -1,6 +1,5 @@ import asyncio import copy -from cgi import parse_header from collections.abc import MutableMapping from functools import partial from typing import List @@ -8,6 +7,7 @@ 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 @@ -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): diff --git a/setup.py b/setup.py index bf3f24f..ee568ab 100644 --- a/setup.py +++ b/setup.py @@ -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 = [ @@ -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", diff --git a/tests/flask/test_graphqlview.py b/tests/flask/test_graphqlview.py index a222381..34ddcb9 100644 --- a/tests/flask/test_graphqlview.py +++ b/tests/flask/test_graphqlview.py @@ -1,5 +1,4 @@ import json -from io import StringIO from urllib.parse import urlencode import pytest @@ -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 diff --git a/tox.ini b/tox.ini index 1c534fd..6627604 100644 --- a/tox.ini +++ b/tox.ini @@ -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 @@ -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