Skip to content

Commit 29204bb

Browse files
committed
Modernise
1 parent de03d5f commit 29204bb

5 files changed

Lines changed: 599 additions & 41 deletions

File tree

cataloguer.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
import os
1010
import re
1111
from collections import defaultdict
12-
from collections.abc import Iterable, Iterator, Mapping, Sequence
12+
from collections.abc import Iterable, Mapping, Sequence
1313
from contextlib import (
1414
AbstractAsyncContextManager,
1515
AsyncExitStack,
@@ -289,7 +289,7 @@ def is_valid_toc(toc_filename: str):
289289
)
290290
for t in tocs
291291
)
292-
toc_ids_by_source: Iterator[tuple[str, ...]] = zip(*toc_ids)
292+
toc_ids_by_source: zip[tuple[str, ...]] = zip(*toc_ids)
293293
project_ids = (next(filter(None, s), None) for s in toc_ids_by_source)
294294

295295
else:
@@ -518,7 +518,9 @@ async def get_projects(token: str):
518518
return projects
519519

520520

521-
async def get_pruned_or_updates_projects(token: str, prune_candidates: Iterable[str]):
521+
async def get_pruned_or_updates_projects(
522+
token: str, prune_candidates: Iterable[str]
523+
) -> Mapping[str, Project | Literal[False]]:
522524
async with _make_http_client(token) as (_, get):
523525

524526
async def get_repo(candidate: str):
@@ -529,12 +531,11 @@ async def get_repo(candidate: str):
529531
except aiohttp.ClientResponseError:
530532
return (candidate, False)
531533

532-
repo_statuses: dict[str, Project | Literal[False]] = {
534+
return {
533535
f: s
534-
for c in asyncio.as_completed([get_repo(f) for f in prune_candidates])
536+
for c in asyncio.as_completed(get_repo(f) for f in prune_candidates)
535537
for (f, s) in (await c,)
536538
}
537-
return repo_statuses
538539

539540

540541
outcsv_argument = click.argument("outcsv", default="addons.csv")

noxfile.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import nox
2+
3+
nox.options.default_venv_backend = "uv"
4+
nox.options.sessions = ["lint"]
5+
6+
7+
@nox.session(name="format")
8+
def format_(session):
9+
session.install("--group", "format")
10+
session.run("ruff", "check", "--select", "I", "--fix")
11+
session.run("ruff", "format")
12+
13+
14+
@nox.session
15+
def lint(session):
16+
session.install("--group", "lint")
17+
session.run("ruff", "check")

pyproject.toml

Lines changed: 24 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ build-backend = "flit_core.buildapi"
66
name = "cataloguer"
77
version = "0.1.0"
88
description = "Script which collects WoW add-on metadata from GitHub"
9-
requires-python = ">= 3.11"
9+
requires-python = ">= 3.12"
1010
license.file = "LICENSE"
1111
dependencies = [
1212
"aiohttp",
@@ -19,45 +19,34 @@ dependencies = [
1919
"yarl",
2020
]
2121

22-
[project.optional-dependencies]
23-
dev = [
24-
"poethepoet",
25-
"ruff",
26-
]
27-
28-
[project.entry-points."pipx.run"]
29-
cataloguer = "cataloguer:cli"
30-
31-
[tool.pyright]
32-
strict = ["cataloguer.py"]
22+
[dependency-groups]
23+
dev = ["basedpyright", { include-group = "lint" }, { include-group = "typing" }]
24+
format = ["ruff"]
25+
lint = [{ include-group = "format" }]
26+
typing = ["diskcache-stubs"]
3327

3428
[tool.ruff]
3529
line-length = 99
3630

3731
[tool.ruff.lint]
3832
select = [
39-
"A", # flake8-builtins
40-
"B0", # flake8-bugbear excl. opinionated rules
41-
"C4", # flake8-comprehensions
42-
"DTZ", # flake8-datetimez
43-
"E", # pycodestyle
44-
"F", # pyflakes
45-
"I", # isort
46-
"PGH", # pygrep-hooks
47-
"PIE", # flake8-pie
48-
"RUF", # ruff
49-
"UP", # pyupgrade
50-
"W", # pycodestyle
33+
"ASYNC", # flake8-async
34+
"B0", # flake8-bugbear (without opinionated rules)
35+
"C4", # flake8-comprehensions
36+
"DTZ", # flake8-datetimez
37+
"E", # pycodestyle
38+
"F", # pyflakes
39+
"I", # isort
40+
"PGH", # pygrep-hooks
41+
"PIE", # flake8-pie
42+
"PT", # flake8-pytest-style
43+
"RUF", # ruff
44+
"TRY", # tryceratops
45+
"UP", # pyupgrade
46+
"W", # pycodestyle
47+
"YTT", # flake8-2020
5148
]
5249

53-
[tool.poe.env]
54-
__POE_TARGET = "cataloguer.py"
55-
56-
[tool.poe.tasks]
57-
_black = "ruff format $__POE_TARGET"
58-
_isort = "ruff --select I --fix $__POE_TARGET"
59-
format.sequence = [
60-
"_black",
61-
"_isort",
62-
]
63-
lint = "ruff --output-format grouped --show-source $__POE_TARGET"
50+
[tool.pyright]
51+
typeCheckingMode = "strict"
52+
# strict = ["cataloguer.py"]

taplo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[formatting]
2+
array_auto_collapse = false
3+
column_width = 99
4+
indent_string = " "

0 commit comments

Comments
 (0)