Skip to content

Commit

Permalink
Drop support of Python 3.7 (#435)
Browse files Browse the repository at this point in the history
  • Loading branch information
fantix committed Sep 22, 2023
1 parent 8d9b96e commit 758a391
Show file tree
Hide file tree
Showing 15 changed files with 27 additions and 117 deletions.
19 changes: 4 additions & 15 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,17 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.7", "3.8", "3.9", "3.10", "3.11"]
python-version: ["3.8", "3.9", "3.10", "3.11"]
edgedb-version: [stable , nightly]
os: [ubuntu-20.04, ubuntu-latest, macos-latest, windows-2019]
os: [ubuntu-latest, macos-latest, windows-2019]
loop: [asyncio, uvloop]
exclude:
# uvloop does not support windows
- loop: uvloop
os: windows-2019
# Python 3.7 on ubuntu-22.04 has a broken OpenSSL 3.0
- python-version: 3.7
os: ubuntu-latest
- python-version: 3.8
os: ubuntu-20.04
- python-version: 3.9
os: ubuntu-20.04
- python-version: 3.10
os: ubuntu-20.04
- python-version: 3.11
os: ubuntu-20.04

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 50
submodules: true
Expand Down Expand Up @@ -109,7 +98,7 @@ jobs:
regression-tests:
name: "Regression Tests"
needs: [test]
runs-on: ubuntu-20.04
runs-on: ubuntu-latest

steps:
- run: echo OK
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ The Python driver for EdgeDB
**edgedb-python** is the official EdgeDB driver for Python.
It provides both blocking IO and asyncio implementations.

The library requires Python 3.7 or later.
The library requires Python 3.8 or later.


Documentation
Expand Down
5 changes: 0 additions & 5 deletions edgedb/_testbase.py
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,3 @@ def gen_lock_key():
if os.environ.get('USE_UVLOOP'):
import uvloop
uvloop.install()
elif sys.platform == 'win32' and sys.version_info[:2] == (3, 7):
# The default policy on win32 of Python 3.7 is SelectorEventLoop, which
# does not implement some subprocess functions required by the tests,
# so we have to manually set it to the proactor one (default in 3.8).
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
5 changes: 2 additions & 3 deletions edgedb/asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

from . import abstract
from . import base_client
from . import compat
from . import con_utils
from . import errors
from . import transaction
Expand Down Expand Up @@ -55,7 +54,7 @@ def is_closed(self):

async def connect_addr(self, addr, timeout):
try:
await compat.wait_for(self._connect_addr(addr), timeout)
await asyncio.wait_for(self._connect_addr(addr), timeout)
except asyncio.TimeoutError as e:
raise TimeoutError from e

Expand Down Expand Up @@ -206,7 +205,7 @@ async def _acquire_impl():
if timeout is None:
return await _acquire_impl()
else:
return await compat.wait_for(
return await asyncio.wait_for(
_acquire_impl(), timeout=timeout)

async def _release(self, holder):
Expand Down
6 changes: 1 addition & 5 deletions edgedb/codegen/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -484,11 +484,7 @@ def _generate_code(
if link_props:
print(file=buf)
self._imports.add("typing")
if SYS_VERSION_INFO >= (3, 8):
typing_literal = "typing.Literal"
else:
self._imports.add("typing_extensions")
typing_literal = "typing_extensions.Literal"
typing_literal = "typing.Literal"
for el_name, el_code in link_props:
print(f"{INDENT}@typing.overload", file=buf)
print(
Expand Down
55 changes: 0 additions & 55 deletions edgedb/compat.py

This file was deleted.

8 changes: 1 addition & 7 deletions edgedb/credentials.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import os
import pathlib
import sys
import typing
import json

if sys.version_info >= (3, 8):
from typing import TypedDict
else:
from typing_extensions import TypedDict

from . import platform


class RequiredCredentials(TypedDict, total=True):
class RequiredCredentials(typing.TypedDict, total=True):
port: int
user: str

Expand Down
4 changes: 0 additions & 4 deletions edgedb/datatypes/namedtuple.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,6 @@ EdgeNamedTuple_New(PyObject *type)
if (nt == NULL) {
return NULL;
}
#if PY_VERSION_HEX < 0x03080000
// Workaround for Python issue 35810; no longer necessary in Python 3.8
Py_INCREF(type);
#endif
}
assert(nt != NULL);
assert(Py_SIZE(nt) == size);
Expand Down
1 change: 0 additions & 1 deletion edgedb/protocol/asyncio_proto.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import asyncio

from edgedb import errors
from edgedb import compat
from edgedb.pgproto.pgproto cimport (
WriteBuffer,
ReadBuffer,
Expand Down
9 changes: 3 additions & 6 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@

import sys

if sys.version_info < (3, 7):
raise RuntimeError('edgedb requires Python 3.7 or greater')
if sys.version_info < (3, 8):
raise RuntimeError('edgedb requires Python 3.8 or greater')

import os
import os.path
Expand Down Expand Up @@ -48,10 +48,8 @@
'pycodestyle~=2.6.0',
'pyflakes~=2.2.0',
'flake8-bugbear~=21.4.3',
# importlib-metadata pinned because flake 3.8.1 will grab a too new one
'importlib-metadata<4.3,>=1.1.0; python_version < "3.8"',
'flake8~=3.8.1',
'uvloop>=0.15.1; platform_system != "Windows" and python_version >= "3.7"',
'uvloop>=0.15.1; platform_system != "Windows"',
]

# Dependencies required to build documentation.
Expand Down Expand Up @@ -339,7 +337,6 @@ def finalize_options(self):
test_suite='tests.suite',
python_requires=">=3.7",
install_requires=[
'typing-extensions>=3.10.0; python_version < "3.8.0"',
'certifi>=2021.5.30; platform_system == "Windows"',
],
extras_require=EXTRA_DEPENDENCIES,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import dataclasses
import datetime
import edgedb
import typing
import typing_extensions
import uuid


Expand All @@ -34,11 +33,11 @@ class LinkPropResultFriendsItem(NoPydanticValidation):
created_at: typing.Optional[datetime.datetime]

@typing.overload
def __getitem__(self, key: typing_extensions.Literal["@created_at"]) -> typing.Optional[datetime.datetime]:
def __getitem__(self, key: typing.Literal["@created_at"]) -> typing.Optional[datetime.datetime]:
...

@typing.overload
def __getitem__(self, key: typing_extensions.Literal["@strength"]) -> typing.Optional[float]:
def __getitem__(self, key: typing.Literal["@strength"]) -> typing.Optional[float]:
...

def __getitem__(self, key: str) -> typing.Any:
Expand Down
13 changes: 8 additions & 5 deletions tests/test_async_query.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,15 @@
import edgedb

from edgedb import abstract
from edgedb import compat
from edgedb import _taskgroup as tg
from edgedb import _testbase as tb
from edgedb.options import RetryOptions
from edgedb.protocol import protocol

try:
from asyncio import TaskGroup
except ImportError:
from edgedb._taskgroup import TaskGroup


class TestAsyncQuery(tb.AsyncQueryTestCase):

Expand Down Expand Up @@ -903,7 +906,7 @@ async def test_async_wait_cancel_01(self):
lock_key))

try:
async with tg.TaskGroup() as g:
async with TaskGroup() as g:

fut = asyncio.Future()

Expand Down Expand Up @@ -935,7 +938,7 @@ async def exec_to_fail():
# cancelled, which, in turn, will terminate the
# connection rudely, and exec_to_fail() will get
# ConnectionResetError.
await compat.wait_for(
await asyncio.wait_for(
client2.aclose(), timeout=0.5
)

Expand Down Expand Up @@ -1029,7 +1032,7 @@ async def test_async_cancel_01(self):
protocol_before = client._impl._holders[0]._con._protocol

with self.assertRaises(asyncio.TimeoutError):
await compat.wait_for(
await asyncio.wait_for(
client.query_single('SELECT sys::_sleep(10)'),
timeout=0.1)

Expand Down
3 changes: 1 addition & 2 deletions tests/test_async_retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import unittest.mock

import edgedb
from edgedb import compat
from edgedb import errors
from edgedb import RetryOptions
from edgedb import _testbase as tb
Expand Down Expand Up @@ -195,7 +194,7 @@ async def transaction1(client):
client = client.with_retry_options(options)
client2 = client2.with_retry_options(options)

results = await compat.wait_for(asyncio.gather(
results = await asyncio.wait_for(asyncio.gather(
transaction1(client),
transaction1(client2),
return_exceptions=True,
Expand Down
7 changes: 3 additions & 4 deletions tests/test_asyncio_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@

import edgedb

from edgedb import compat
from edgedb import _testbase as tb
from edgedb import errors
from edgedb import asyncio_client
Expand Down Expand Up @@ -304,7 +303,7 @@ async def worker():

with self.assertRaises(asyncio.TimeoutError):
await flag
await compat.wait_for(client.aclose(), timeout=0.1)
await asyncio.wait_for(client.aclose(), timeout=0.1)

with self.assertRaises(errors.ClientConnectionClosedError):
await task
Expand Down Expand Up @@ -335,7 +334,7 @@ async def close(self, timeout=None):
async with tx:
await tx.query("SELECT 42")
with self.assertRaises(asyncio.TimeoutError):
await compat.wait_for(client.query("SELECT 42"), 1)
await asyncio.wait_for(client.query("SELECT 42"), 1)

await client.aclose()

Expand Down Expand Up @@ -445,7 +444,7 @@ async def cb(r: asyncio.StreamReader, w: asyncio.StreamWriter):
finally:
server.close()
await server.wait_closed()
await compat.wait_for(client.aclose(), 5)
await asyncio.wait_for(client.aclose(), 5)
broken.set()
await done.wait()

Expand Down
2 changes: 1 addition & 1 deletion tests/test_codegen.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ async def run(*args, extra_env=None):

cmd = env.get("EDGEDB_PYTHON_TEST_CODEGEN_CMD", "edgedb-py")
await run(
cmd, extra_env={"EDGEDB_PYTHON_CODEGEN_PY_VER": "3.7.5"}
cmd, extra_env={"EDGEDB_PYTHON_CODEGEN_PY_VER": "3.8.5"}
)
await run(
cmd,
Expand Down

0 comments on commit 758a391

Please sign in to comment.