Skip to content

Commit 0bc358b

Browse files
committed
chore: Template upgrade
1 parent 664aece commit 0bc358b

File tree

10 files changed

+76
-29
lines changed

10 files changed

+76
-29
lines changed

.copier-answers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Changes here will be overwritten by Copier.
2-
_commit: 1.8.4
2+
_commit: 1.8.9
33
_src_path: gh:pawamoy/copier-uv
44
author_email: [email protected]
55
author_fullname: Timothée Mazzucotelli

Makefile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,13 @@
22
# the `make` command will point at the `scripts/make` shell script.
33
# This Makefile is just here to allow auto-completion in the terminal.
44

5+
default: help
6+
@echo
7+
@echo 'Enable direnv in your shell to use the `make` command: `direnv allow`'
8+
@echo 'Or use `python scripts/make ARGS` to run the commands/tasks directly.'
9+
10+
.DEFAULT_GOAL: default
11+
512
actions = \
613
allrun \
714
changelog \

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
[![documentation](https://img.shields.io/badge/docs-mkdocs-708FCC.svg?style=flat)](https://mkdocstrings.github.io/autorefs/)
55
[![pypi version](https://img.shields.io/pypi/v/mkdocs-autorefs.svg)](https://pypi.org/project/mkdocs-autorefs/)
66
[![conda version](https://img.shields.io/conda/vn/conda-forge/mkdocs-autorefs.svg)](https://anaconda.org/conda-forge/mkdocs-autorefs)
7-
[![gitpod](https://img.shields.io/badge/gitpod-workspace-708FCC.svg?style=flat)](https://gitpod.io/#https://github.com/mkdocstrings/autorefs)
8-
[![gitter](https://badges.gitter.im/join%20chat.svg)](https://app.gitter.im/#/room/#autorefs:gitter.im)
7+
[![gitter](https://img.shields.io/badge/matrix-chat-4DB798.svg?style=flat)](https://app.gitter.im/#/room/#autorefs:gitter.im)
98

109
Automatically link across pages in MkDocs.
1110

duties.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
WINDOWS = os.name == "nt"
2626
PTY = not WINDOWS and not CI
2727
MULTIRUN = os.environ.get("MULTIRUN", "0") == "1"
28+
PY_VERSION = f"{sys.version_info.major}{sys.version_info.minor}"
29+
PY_DEV = "314"
2830

2931

3032
def pyprefix(title: str) -> str:
@@ -68,7 +70,7 @@ def check(ctx: Context) -> None:
6870
"""Check it all!"""
6971

7072

71-
@duty
73+
@duty(nofail=PY_VERSION == PY_DEV)
7274
def check_quality(ctx: Context) -> None:
7375
"""Check the code quality."""
7476
ctx.run(
@@ -77,7 +79,7 @@ def check_quality(ctx: Context) -> None:
7779
)
7880

7981

80-
@duty
82+
@duty(nofail=PY_VERSION == PY_DEV)
8183
def check_docs(ctx: Context) -> None:
8284
"""Check if the documentation builds correctly."""
8385
Path("htmlcov").mkdir(parents=True, exist_ok=True)
@@ -89,7 +91,7 @@ def check_docs(ctx: Context) -> None:
8991
)
9092

9193

92-
@duty
94+
@duty(nofail=PY_VERSION == PY_DEV)
9395
def check_types(ctx: Context) -> None:
9496
"""Check that the code is correctly typed."""
9597
os.environ["FORCE_COLOR"] = "1"
@@ -99,7 +101,7 @@ def check_types(ctx: Context) -> None:
99101
)
100102

101103

102-
@duty
104+
@duty(nofail=PY_VERSION == PY_DEV)
103105
def check_api(ctx: Context, *cli_args: str) -> None:
104106
"""Check for API breaking changes."""
105107
ctx.run(
@@ -192,15 +194,14 @@ def coverage(ctx: Context) -> None:
192194
ctx.run(tools.coverage.html(rcfile="config/coverage.ini"))
193195

194196

195-
@duty
196-
def test(ctx: Context, *cli_args: str, match: str = "") -> None:
197+
@duty(nofail=PY_VERSION == PY_DEV)
198+
def test(ctx: Context, *cli_args: str, match: str = "") -> None: # noqa: PT028
197199
"""Run the test suite.
198200
199201
Parameters:
200202
match: A pytest expression to filter selected tests.
201203
"""
202-
py_version = f"{sys.version_info.major}{sys.version_info.minor}"
203-
os.environ["COVERAGE_FILE"] = f".coverage.{py_version}"
204+
os.environ["COVERAGE_FILE"] = f".coverage.{PY_VERSION}"
204205
ctx.run(
205206
tools.pytest(
206207
"tests",

scripts/get_version.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@
44
from contextlib import suppress
55
from pathlib import Path
66

7-
from pdm.backend.hooks.version import SCMVersion, Version, default_version_formatter, get_version_from_scm
7+
from pdm.backend.hooks.version import ( # ty: ignore[unresolved-import]
8+
SCMVersion,
9+
Version,
10+
default_version_formatter,
11+
get_version_from_scm,
12+
)
813

914
_root = Path(__file__).parent.parent
1015
_changelog = _root / "CHANGELOG.md"

scripts/make.py

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616

1717
PYTHON_VERSIONS = os.getenv("PYTHON_VERSIONS", "3.9 3.10 3.11 3.12 3.13 3.14").split()
18+
PYTHON_DEV = "3.14"
1819

1920

2021
def shell(cmd: str, *, capture_output: bool = False, **kwargs: Any) -> str | None:
@@ -67,16 +68,31 @@ def setup() -> None:
6768
uv_install(venv_path)
6869

6970

71+
class _RunError(subprocess.CalledProcessError):
72+
def __init__(self, *args: Any, python_version: str, **kwargs: Any):
73+
super().__init__(*args, **kwargs)
74+
self.python_version = python_version
75+
76+
7077
def run(version: str, cmd: str, *args: str, **kwargs: Any) -> None:
7178
"""Run a command in a virtual environment."""
7279
kwargs = {"check": True, **kwargs}
7380
uv_run = ["uv", "run", "--no-sync"]
74-
if version == "default":
75-
with environ(UV_PROJECT_ENVIRONMENT=".venv"):
76-
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
77-
else:
78-
with environ(UV_PROJECT_ENVIRONMENT=f".venvs/{version}", MULTIRUN="1"):
79-
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
81+
try:
82+
if version == "default":
83+
with environ(UV_PROJECT_ENVIRONMENT=".venv"):
84+
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
85+
else:
86+
with environ(UV_PROJECT_ENVIRONMENT=f".venvs/{version}", MULTIRUN="1"):
87+
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
88+
except subprocess.CalledProcessError as process:
89+
raise _RunError(
90+
returncode=process.returncode,
91+
python_version=version,
92+
cmd=process.cmd,
93+
output=process.output,
94+
stderr=process.stderr,
95+
) from process
8096

8197

8298
def multirun(cmd: str, *args: str, **kwargs: Any) -> None:
@@ -144,19 +160,31 @@ def main() -> int:
144160
cmd = args.pop(0)
145161

146162
if cmd == "run":
147-
run("default", *args)
163+
if not args:
164+
print("make: run: missing command", file=sys.stderr)
165+
return 1
166+
run("default", *args) # ty: ignore[missing-argument]
148167
return 0
149168

150169
if cmd == "multirun":
151-
multirun(*args)
170+
if not args:
171+
print("make: run: missing command", file=sys.stderr)
172+
return 1
173+
multirun(*args) # ty: ignore[missing-argument]
152174
return 0
153175

154176
if cmd == "allrun":
155-
allrun(*args)
177+
if not args:
178+
print("make: run: missing command", file=sys.stderr)
179+
return 1
180+
allrun(*args) # ty: ignore[missing-argument]
156181
return 0
157182

158183
if cmd.startswith("3."):
159-
run(cmd, *args)
184+
if not args:
185+
print("make: run: missing command", file=sys.stderr)
186+
return 1
187+
run(cmd, *args) # ty: ignore[missing-argument]
160188
return 0
161189

162190
opts = []
@@ -183,7 +211,14 @@ def main() -> int:
183211
if __name__ == "__main__":
184212
try:
185213
sys.exit(main())
186-
except subprocess.CalledProcessError as process:
214+
except _RunError as process:
187215
if process.output:
188216
print(process.output, file=sys.stderr)
189-
sys.exit(process.returncode)
217+
if (code := process.returncode) == 139: # noqa: PLR2004
218+
print(
219+
f"✗ (python{process.python_version}) '{' '.join(process.cmd)}' failed with return code {code} (segfault)",
220+
file=sys.stderr,
221+
)
222+
if process.python_version == PYTHON_DEV:
223+
code = 0
224+
sys.exit(code)

src/mkdocs_autorefs/_internal/backlinks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727

2828
@dataclass(frozen=True, order=True)
29-
class BacklinkCrumb:
29+
class BacklinkCrumb: # noqa: PLW1641
3030
"""A navigation breadcrumb for a backlink."""
3131

3232
title: str

src/mkdocs_autorefs/_internal/debug.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ def _get_debug_info() -> _Environment:
8585
interpreter_version=py_version,
8686
interpreter_path=sys.executable,
8787
platform=platform.platform(),
88-
variables=[_Variable(var, val) for var in variables if (val := os.getenv(var))],
88+
variables=[_Variable(var, val) for var in variables if (val := os.getenv(var))], # ty: ignore[invalid-argument-type]
8989
packages=[_Package(pkg, _get_version(pkg)) for pkg in packages],
9090
)
9191

src/mkdocs_autorefs/_internal/plugin.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ def _map_urls(self, page: Page, anchor: AnchorLink, parent: BacklinkCrumb | None
317317
try:
318318
page = self._url_to_page[page]
319319
except KeyError:
320-
page = self.current_page
320+
page = self.current_page # type: ignore[assignment]
321321

322322
self.register_anchor(page, anchor.id, title=anchor.title, primary=True)
323323
breadcrumb = self._get_breadcrumb(page, anchor, parent)
@@ -427,7 +427,7 @@ def register_anchor(
427427
try:
428428
page = self._url_to_page[page]
429429
except KeyError:
430-
page = self.current_page
430+
page = self.current_page # type: ignore[assignment]
431431

432432
url = f"{page.url}#{anchor or identifier}"
433433
url_map = self._primary_url_map if primary else self._secondary_url_map

tests/test_api.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ def _fixture_public_objects(public_api: griffe.Module) -> list[griffe.Object | g
9191
def _fixture_inventory() -> Inventory:
9292
inventory_file = Path(__file__).parent.parent / "site" / "objects.inv"
9393
if not inventory_file.exists():
94-
raise pytest.skip("The objects inventory is not available.")
94+
pytest.skip("The objects inventory is not available.") # ty: ignore[call-non-callable]
9595
with inventory_file.open("rb") as file:
9696
return Inventory.parse_sphinx(file)
9797

0 commit comments

Comments
 (0)