Skip to content

Remove Python 3.7 support - cleaning old code #495

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# GQL

This is a GraphQL client for Python 3.7+.
This is a GraphQL client for Python 3.8+.
Plays nicely with `graphene`, `graphql-core`, `graphql-js` and any other GraphQL implementation compatible with the spec.

GQL architecture is inspired by `React-Relay` and `Apollo-Client`.
Expand Down
2 changes: 1 addition & 1 deletion docs/gql-cli/intro.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
gql-cli
=======

GQL provides a python 3.7+ script, called `gql-cli` which allows you to execute
GQL provides a python script, called `gql-cli` which allows you to execute
GraphQL queries directly from the terminal.

This script supports http(s) or websockets protocols.
Expand Down
2 changes: 1 addition & 1 deletion docs/intro.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Introduction
============

`GQL 3`_ is a `GraphQL`_ Client for Python 3.7+ which plays nicely with other
`GQL 3`_ is a `GraphQL`_ Client for Python 3.8+ which plays nicely with other
graphql implementations compatible with the spec.

Under the hood, it uses `GraphQL-core`_ which is a Python port of `GraphQL.js`_,
Expand Down
17 changes: 3 additions & 14 deletions gql/client.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import logging
import sys
import time
import warnings
from concurrent.futures import Future
Expand All @@ -13,6 +12,7 @@
Dict,
Generator,
List,
Literal,
Optional,
Tuple,
TypeVar,
Expand Down Expand Up @@ -44,17 +44,6 @@
from .utilities import serialize_variable_values
from .utils import str_first_element

"""
Load the appropriate instance of the Literal type
Note: we cannot use try: except ImportError because of the following mypy issue:
https://github.com/python/mypy/issues/8520
"""
if sys.version_info[:2] >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal # pragma: no cover


log = logging.getLogger(__name__)


Expand Down Expand Up @@ -1368,8 +1357,8 @@ async def _subscribe(
**kwargs,
)

# Keep a reference to the inner generator to allow the user to call aclose()
# before a break if python version is too old (pypy3 py 3.6.1)
# Keep a reference to the inner generator
# This is only used for the tests to simulate a KeyboardInterrupt event
self._generator = inner_generator

try:
Expand Down
17 changes: 1 addition & 16 deletions gql/transport/aiohttp_websockets.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import asyncio
import json
import logging
import sys
import warnings
from contextlib import suppress
from ssl import SSLContext
Expand All @@ -10,6 +9,7 @@
AsyncGenerator,
Collection,
Dict,
Literal,
Mapping,
Optional,
Tuple,
Expand All @@ -32,16 +32,6 @@
TransportServerError,
)

"""
Load the appropriate instance of the Literal type
Note: we cannot use try: except ImportError because of the following mypy issue:
https://github.com/python/mypy/issues/8520
"""
if sys.version_info[:2] >= (3, 8):
from typing import Literal
else:
from typing_extensions import Literal # pragma: no cover

log = logging.getLogger("gql.transport.aiohttp_websockets")

ParsedAnswer = Tuple[str, Optional[ExecutionResult]]
Expand Down Expand Up @@ -1124,11 +1114,6 @@ async def execute(

async for result in generator:
first_result = result

# Note: we need to run generator.aclose() here or the finally block in
# the subscribe will not be reached in pypy3 (python version 3.6.1)
await generator.aclose()

break

if first_result is None:
Expand Down
5 changes: 0 additions & 5 deletions gql/transport/websockets_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,11 +431,6 @@ async def execute(

async for result in generator:
first_result = result

# Note: we need to run generator.aclose() here or the finally block in
# the subscribe will not be reached in pypy3 (python version 3.6.1)
await generator.aclose()

break

if first_result is None:
Expand Down
19 changes: 0 additions & 19 deletions tests/custom_scalars/test_datetime.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from datetime import datetime, timedelta
from typing import Any, Dict, Optional

import pytest
from graphql.error import GraphQLError
from graphql.language import ValueNode
from graphql.pyutils import inspect
Expand Down Expand Up @@ -110,9 +109,6 @@ def resolve_seconds(root, _info, interval):
schema = GraphQLSchema(query=queryType)


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_shift_days():

client = Client(schema=schema, parse_results=True, serialize_variables=True)
Expand All @@ -132,9 +128,6 @@ def test_shift_days():
assert result["shiftDays"] == datetime.fromisoformat("2021-11-17T11:58:13.461161")


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_shift_days_serialized_manually_in_query():

client = Client(schema=schema)
Expand All @@ -152,9 +145,6 @@ def test_shift_days_serialized_manually_in_query():
assert result["shiftDays"] == datetime.fromisoformat("2021-11-17T11:58:13.461161")


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_shift_days_serialized_manually_in_variables():

client = Client(schema=schema, parse_results=True)
Expand All @@ -172,9 +162,6 @@ def test_shift_days_serialized_manually_in_variables():
assert result["shiftDays"] == datetime.fromisoformat("2021-11-17T11:58:13.461161")


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_latest():

client = Client(schema=schema, parse_results=True)
Expand All @@ -197,9 +184,6 @@ def test_latest():
assert result["latest"] == in_five_days


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_seconds():
client = Client(schema=schema)

Expand All @@ -221,9 +205,6 @@ def test_seconds():
assert result["seconds"] == 432000


@pytest.mark.skipif(
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
)
def test_seconds_omit_optional_start_argument():
client = Client(schema=schema)

Expand Down
3 changes: 0 additions & 3 deletions tests/test_aiohttp_websocket_graphqlws_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ async def test_aiohttp_websocket_graphqlws_subscription_break(
assert number == count

if count <= 5:
# Note: the following line is only necessary for pypy3 v3.6.1
if sys.version_info < (3, 7):
await session._generator.aclose()
break

count -= 1
Expand Down
3 changes: 0 additions & 3 deletions tests/test_aiohttp_websocket_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,9 +258,6 @@ async def test_aiohttp_websocket_subscription_break(
assert number == count

if count <= 5:
# Note: the following line is only necessary for pypy3 v3.6.1
if sys.version_info < (3, 7):
await session._generator.aclose()
break

count -= 1
Expand Down
3 changes: 0 additions & 3 deletions tests/test_graphqlws_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,6 @@ async def test_graphqlws_subscription_break(
assert number == count

if count <= 5:
# Note: the following line is only necessary for pypy3 v3.6.1
if sys.version_info < (3, 7):
await session._generator.aclose()
break

count -= 1
Expand Down
11 changes: 0 additions & 11 deletions tests/test_phoenix_channel_subscription.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import asyncio
import json
import sys

import pytest
from parse import search
Expand Down Expand Up @@ -208,11 +207,6 @@ async def test_phoenix_channel_subscription(

assert number == count
if number == end_count:
# Note: we need to run generator.aclose() here or the finally block in
# the subscribe will not be reached in pypy3 (python version 3.6.1)
# In more recent versions, 'break' will trigger __aexit__.
if sys.version_info < (3, 7):
await session._generator.aclose()
print("break")
break

Expand Down Expand Up @@ -390,11 +384,6 @@ async def test_phoenix_channel_heartbeat(event_loop, server, subscription_str):

assert heartbeat_count == i
if heartbeat_count == 5:
# Note: we need to run generator.aclose() here or the finally block in
# the subscribe will not be reached in pypy3 (python version 3.6.1)
# In more recent versions, 'break' will trigger __aexit__.
if sys.version_info < (3, 7):
await session._generator.aclose()
break

i += 1
3 changes: 0 additions & 3 deletions tests/test_websocket_subscription.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,6 @@ async def test_websocket_subscription_break(
assert number == count

if count <= 5:
# Note: the following line is only necessary for pypy3 v3.6.1
if sys.version_info < (3, 7):
await session._generator.aclose()
break

count -= 1
Expand Down
5 changes: 2 additions & 3 deletions tox.ini
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
[tox]
envlist =
black,flake8,import-order,mypy,manifest,
py{37,38,39,310,311,312,py3}
py{38,39,310,311,312,py3}

[gh-actions]
python =
3.7: py37
3.8: py38
3.9: py39
3.10: py310
Expand All @@ -29,7 +28,7 @@ deps = -e.[test]
commands =
pip install -U setuptools
; run "tox -- tests -s" to show output for debugging
py{37,39,310,311,312,py3}: pytest {posargs:tests}
py{39,310,311,312,py3}: pytest {posargs:tests}
py{38}: pytest {posargs:tests --cov-report=term-missing --cov=gql}

[testenv:black]
Expand Down
Loading