Skip to content

Commit bab60f5

Browse files
authored
Python 3.10 compatibility (#2)
1 parent 8ff6224 commit bab60f5

File tree

6 files changed

+34
-32
lines changed

6 files changed

+34
-32
lines changed

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
persist-credentials: false
2626
- uses: actions/setup-python@v5
2727
with:
28-
python-version: "3.11"
28+
python-version: "3.10"
2929
- uses: astral-sh/ruff-action@57714a7c8a2e59f32539362ba31877a1957dded1 # v3.5.1
3030
with:
3131
version: "0.12.11"

README.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ Run with custom options:
481481
Requirements
482482
============
483483

484-
- Python 3.11+
484+
- Python 3.10+
485485
- click >= 8.1.0
486486
- coverage >= 7.4
487487
- typing-extensions >= 4.14.0

pyproject.toml

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ authors = [
66
{ name = "Gel Contributors" },
77
]
88
version = "1.0.0"
9-
requires-python = ">=3.11.0"
9+
requires-python = ">=3.10.0"
1010
readme = "README.rst"
1111
license = { text = "Apache License, Version 2.0" }
1212
keywords = ["gel", "edgedb", "database", "test"]
@@ -64,7 +64,7 @@ exclude = [
6464
"^target",
6565
]
6666
files = ["src/**/*.py"]
67-
python_version = "3.11"
67+
python_version = "3.10"
6868
follow_imports = "normal"
6969
strict = true
7070
ignore_errors = false
@@ -77,15 +77,15 @@ local_partial_types = true
7777

7878
[tool.pyright]
7979
include = ["src/**"]
80-
pythonVersion = "3.11"
80+
pythonVersion = "3.10"
8181
typeCheckingMode = "standard"
8282

8383
# ========================
8484
# BLACK
8585
# ========================
8686
[tool.black]
8787
line-length = 79
88-
target-version = ["py311"]
88+
target-version = ["py310"]
8989

9090
# ========================
9191
# RUFF
@@ -94,7 +94,7 @@ target-version = ["py311"]
9494
[tool.ruff]
9595
line-length = 79
9696
indent-width = 4
97-
target-version = "py311"
97+
target-version = "py310"
9898
exclude = [".github", ".git", "build", "dist", ".eggs"]
9999

100100
[tool.ruff.lint]
@@ -156,4 +156,5 @@ extend-ignore = [
156156
"SIM117", # multiple-with-statements
157157
"UP045", # non-pep604-annotation-optional
158158
"PLR5501", # collapsible-else-if
159+
"PERF203" # try-except-in-loop
159160
]

src/geltest/_internal/fixtures.py

Lines changed: 24 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from __future__ import annotations
22
from typing import TYPE_CHECKING, Protocol
3-
from typing_extensions import TypeAliasType, TypedDict
4-
from typing import Required
3+
from typing_extensions import TypeAliasType, TypedDict, Required
54

65
import asyncio
76
import functools
@@ -227,27 +226,29 @@ async def _call_session_phase(
227226
for case in eligible:
228227
await callback(test_case=case, stats=stats, options=options, ui=ui)
229228
else:
230-
async with asyncio.TaskGroup() as g:
231-
# Use a semaphore to limit the concurrency of bootstrap
232-
# tasks to the number of jobs (bootstrap is heavy, having
233-
# more tasks than `--jobs` won't necessarily make
234-
# things faster.)
235-
sem = asyncio.BoundedSemaphore(num_jobs)
236-
237-
async def controller(
238-
cb: _PhaseCallback,
239-
test_case: type[loader.DatabaseTestCaseProto],
240-
) -> None:
241-
async with sem:
242-
await cb(
243-
test_case=test_case,
244-
stats=stats,
245-
options=options,
246-
ui=ui,
247-
)
248-
249-
for case in eligible:
250-
g.create_task(controller(callback, case))
229+
# Use a semaphore to limit the concurrency of bootstrap
230+
# tasks to the number of jobs (bootstrap is heavy, having
231+
# more tasks than `--jobs` won't necessarily make
232+
# things faster.)
233+
sem = asyncio.BoundedSemaphore(num_jobs)
234+
235+
async def controller(
236+
test_case: type[loader.DatabaseTestCaseProto],
237+
) -> None:
238+
async with sem:
239+
await callback(
240+
test_case=test_case,
241+
stats=stats,
242+
options=options,
243+
ui=ui,
244+
)
245+
246+
if sys.version_info >= (3, 11):
247+
async with asyncio.TaskGroup() as g:
248+
for case in eligible:
249+
g.create_task(controller(case))
250+
else:
251+
await asyncio.gather(controller(case) for case in eligible)
251252

252253
ui.text("\n")
253254

src/geltest/_internal/results.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ def render_result(file: TextIO, result: TestResult) -> None:
299299

300300

301301
def _result_log_path(path_template: str) -> pathlib.Path | None:
302-
now = str(datetime.datetime.now(datetime.UTC)).replace(" ", "_")
302+
now = str(datetime.datetime.now(datetime.timezone.utc)).replace(" ", "_")
303303
path = pathlib.Path(path_template.replace("%TIMESTAMP%", now))
304304

305305
parent_dir = path.parent

src/geltest/_internal/runner.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1321,7 +1321,7 @@ def run(
13211321
result.test_stats + setup_stats + teardown_stats
13221322
):
13231323
name = str(test_obj)
1324-
t = stat["running-time"]
1324+
t = stat.get("running-time", 0)
13251325
at, c = stats.get(name, (0, 0))
13261326
stats[name] = (at + (t - at) / (c + 1), c + 1)
13271327
running_times_log_file.seek(0)

0 commit comments

Comments
 (0)