Skip to content

Commit 9af5146

Browse files
authored
Remove Python 3.7 support - cleaning old code (#495)
1 parent 00b61d5 commit 9af5146

13 files changed

+9
-83
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# GQL
22

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

66
GQL architecture is inspired by `React-Relay` and `Apollo-Client`.

docs/gql-cli/intro.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
gql-cli
44
=======
55

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

99
This script supports http(s) or websockets protocols.

docs/intro.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Introduction
22
============
33

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

77
Under the hood, it uses `GraphQL-core`_ which is a Python port of `GraphQL.js`_,

gql/client.py

+3-14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import asyncio
22
import logging
3-
import sys
43
import time
54
import warnings
65
from concurrent.futures import Future
@@ -13,6 +12,7 @@
1312
Dict,
1413
Generator,
1514
List,
15+
Literal,
1616
Optional,
1717
Tuple,
1818
TypeVar,
@@ -44,17 +44,6 @@
4444
from .utilities import serialize_variable_values
4545
from .utils import str_first_element
4646

47-
"""
48-
Load the appropriate instance of the Literal type
49-
Note: we cannot use try: except ImportError because of the following mypy issue:
50-
https://github.com/python/mypy/issues/8520
51-
"""
52-
if sys.version_info[:2] >= (3, 8):
53-
from typing import Literal
54-
else:
55-
from typing_extensions import Literal # pragma: no cover
56-
57-
5847
log = logging.getLogger(__name__)
5948

6049

@@ -1368,8 +1357,8 @@ async def _subscribe(
13681357
**kwargs,
13691358
)
13701359

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

13751364
try:

gql/transport/aiohttp_websockets.py

+1-16
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import asyncio
22
import json
33
import logging
4-
import sys
54
import warnings
65
from contextlib import suppress
76
from ssl import SSLContext
@@ -10,6 +9,7 @@
109
AsyncGenerator,
1110
Collection,
1211
Dict,
12+
Literal,
1313
Mapping,
1414
Optional,
1515
Tuple,
@@ -32,16 +32,6 @@
3232
TransportServerError,
3333
)
3434

35-
"""
36-
Load the appropriate instance of the Literal type
37-
Note: we cannot use try: except ImportError because of the following mypy issue:
38-
https://github.com/python/mypy/issues/8520
39-
"""
40-
if sys.version_info[:2] >= (3, 8):
41-
from typing import Literal
42-
else:
43-
from typing_extensions import Literal # pragma: no cover
44-
4535
log = logging.getLogger("gql.transport.aiohttp_websockets")
4636

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

11251115
async for result in generator:
11261116
first_result = result
1127-
1128-
# Note: we need to run generator.aclose() here or the finally block in
1129-
# the subscribe will not be reached in pypy3 (python version 3.6.1)
1130-
await generator.aclose()
1131-
11321117
break
11331118

11341119
if first_result is None:

gql/transport/websockets_base.py

-5
Original file line numberDiff line numberDiff line change
@@ -431,11 +431,6 @@ async def execute(
431431

432432
async for result in generator:
433433
first_result = result
434-
435-
# Note: we need to run generator.aclose() here or the finally block in
436-
# the subscribe will not be reached in pypy3 (python version 3.6.1)
437-
await generator.aclose()
438-
439434
break
440435

441436
if first_result is None:

tests/custom_scalars/test_datetime.py

-19
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from datetime import datetime, timedelta
22
from typing import Any, Dict, Optional
33

4-
import pytest
54
from graphql.error import GraphQLError
65
from graphql.language import ValueNode
76
from graphql.pyutils import inspect
@@ -110,9 +109,6 @@ def resolve_seconds(root, _info, interval):
110109
schema = GraphQLSchema(query=queryType)
111110

112111

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

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

134130

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

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

154147

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

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

174164

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

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

199186

200-
@pytest.mark.skipif(
201-
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
202-
)
203187
def test_seconds():
204188
client = Client(schema=schema)
205189

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

223207

224-
@pytest.mark.skipif(
225-
not hasattr(datetime, "fromisoformat"), reason="fromisoformat is new in Python 3.7+"
226-
)
227208
def test_seconds_omit_optional_start_argument():
228209
client = Client(schema=schema)
229210

tests/test_aiohttp_websocket_graphqlws_subscription.py

-3
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ async def test_aiohttp_websocket_graphqlws_subscription_break(
268268
assert number == count
269269

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

276273
count -= 1

tests/test_aiohttp_websocket_subscription.py

-3
Original file line numberDiff line numberDiff line change
@@ -258,9 +258,6 @@ async def test_aiohttp_websocket_subscription_break(
258258
assert number == count
259259

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

266263
count -= 1

tests/test_graphqlws_subscription.py

-3
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,6 @@ async def test_graphqlws_subscription_break(
268268
assert number == count
269269

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

276273
count -= 1

tests/test_phoenix_channel_subscription.py

-11
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import asyncio
22
import json
3-
import sys
43

54
import pytest
65
from parse import search
@@ -208,11 +207,6 @@ async def test_phoenix_channel_subscription(
208207

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

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

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

400389
i += 1

tests/test_websocket_subscription.py

-3
Original file line numberDiff line numberDiff line change
@@ -189,9 +189,6 @@ async def test_websocket_subscription_break(
189189
assert number == count
190190

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

197194
count -= 1

tox.ini

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
[tox]
22
envlist =
33
black,flake8,import-order,mypy,manifest,
4-
py{37,38,39,310,311,312,py3}
4+
py{38,39,310,311,312,py3}
55

66
[gh-actions]
77
python =
8-
3.7: py37
98
3.8: py38
109
3.9: py39
1110
3.10: py310
@@ -29,7 +28,7 @@ deps = -e.[test]
2928
commands =
3029
pip install -U setuptools
3130
; run "tox -- tests -s" to show output for debugging
32-
py{37,39,310,311,312,py3}: pytest {posargs:tests}
31+
py{39,310,311,312,py3}: pytest {posargs:tests}
3332
py{38}: pytest {posargs:tests --cov-report=term-missing --cov=gql}
3433

3534
[testenv:black]

0 commit comments

Comments
 (0)