chore: Template upgrade

This commit is contained in:
Timothée Mazzucotelli
2025-02-03 02:43:46 +01:00
parent 84d7fedfd0
commit 275129180b
6 changed files with 37 additions and 14 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
# Changes here will be overwritten by Copier
_commit: 1.5.4
_commit: 1.5.7
_src_path: gh:pawamoy/copier-uv
author_email: dev@pawamoy.fr
author_fullname: Timothée Mazzucotelli
+2
View File
@@ -88,6 +88,8 @@ else:
```
<!-- blacken-docs:on -->
Additionally, your sponsorship will give more weight to your upvotes on issues, helping us prioritize work items in our backlog. For more information on how we prioritize work, see this page: [Backlog management](https://pawamoy.github.io/backlog/).
## How to become a sponsor
Thanks for your interest in sponsoring! In order to become an eligible sponsor
+1
View File
@@ -88,6 +88,7 @@ def check_docs(ctx: Context) -> None:
@duty
def check_types(ctx: Context) -> None:
"""Check that the code is correctly typed."""
os.environ["FORCE_COLOR"] = "1"
ctx.run(
tools.mypy(*PY_SRC_LIST, config_file="config/mypy.ini"),
title=pyprefix("Type-checking"),
+3 -8
View File
@@ -48,13 +48,11 @@ Funding = "https://github.com/sponsors/pawamoy"
[project.entry-points."mkdocs.plugins"]
markdown-exec = "markdown_exec.mkdocs_plugin:MarkdownExecPlugin"
[tool.pdm]
version = {source = "scm"}
[tool.pdm.version]
source = "call"
getter = "scripts.get_version:get_version"
[tool.pdm.build]
package-dir = "src"
editable-backend = "editables"
# Include as much as possible in the source distribution, to help redistributors.
excludes = ["**/.pytest_cache"]
source-includes = [
@@ -79,9 +77,6 @@ data = [
[dependency-groups]
dev = [
# dev
"editables>=0.5",
# maintenance
"build>=1.2",
"git-changelog>=2.5",
+27
View File
@@ -0,0 +1,27 @@
"""Get current project version from Git tags or changelog."""
import re
from contextlib import suppress
from pathlib import Path
from pdm.backend.hooks.version import SCMVersion, Version, default_version_formatter, get_version_from_scm
_root = Path(__file__).parent.parent
_changelog = _root / "CHANGELOG.md"
_changelog_version_re = re.compile(r"^## \[(\d+\.\d+\.\d+)\].*$")
_default_scm_version = SCMVersion(Version("0.0.0"), None, False, None, None) # noqa: FBT003
def get_version() -> str:
"""Get current project version from Git tags or changelog."""
scm_version = get_version_from_scm(_root) or _default_scm_version
if scm_version.version <= Version("0.1"): # Missing Git tags?
with suppress(OSError, StopIteration): # noqa: SIM117
with _changelog.open("r", encoding="utf8") as file:
match = next(filter(None, map(_changelog_version_re.match, file)))
scm_version = scm_version._replace(version=Version(match.group(1)))
return default_version_formatter(scm_version)
if __name__ == "__main__":
print(get_version())
+3 -5
View File
@@ -69,12 +69,10 @@ def setup() -> None:
uv_install(venv_path)
def run(version: str, cmd: str, *args: str, no_sync: bool = False, **kwargs: Any) -> None:
def run(version: str, cmd: str, *args: str, **kwargs: Any) -> None:
"""Run a command in a virtual environment."""
kwargs = {"check": True, **kwargs}
uv_run = ["uv", "run"]
if no_sync:
uv_run.append("--no-sync")
uv_run = ["uv", "run", "--no-sync"]
if version == "default":
with environ(UV_PROJECT_ENVIRONMENT=".venv"):
subprocess.run([*uv_run, cmd, *args], **kwargs) # noqa: S603, PLW1510
@@ -141,7 +139,7 @@ def main() -> int:
)
if os.path.exists(".venv"):
print("\nAvailable tasks", flush=True)
run("default", "duty", "--list", no_sync=True)
run("default", "duty", "--list")
return 0
while args: