diff --git a/.copier-answers.yml b/.copier-answers.yml index cd5b996..f12636c 100644 --- a/.copier-answers.yml +++ b/.copier-answers.yml @@ -1,5 +1,5 @@ # Changes here will be overwritten by Copier; NEVER EDIT MANUALLY -_commit: 2024.1.1-41-g4b4fb7f +_commit: 2024.1.1-60-gedf2667 _src_path: gh:blakeNaccarato/copier-python actions_runner: ubuntu-22.04 active: true diff --git a/.vscode/launch.json b/.vscode/launch.json index cff6b3d..599fd09 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,14 +8,6 @@ } ], "configurations": [ - { - "name": "Python: Sphinx build docs", - "type": "debugpy", - "request": "launch", - "module": "sphinx", - "args": ["-EaT", "docs", "_site"], - "console": "internalConsole" - }, { "name": "Python: Current file", "type": "debugpy", @@ -37,6 +29,14 @@ "args": ["${input:input}"], "console": "internalConsole" }, + { + "name": "Python: Sphinx build docs", + "type": "debugpy", + "request": "launch", + "module": "sphinx", + "args": ["-EaT", "docs", "_site"], + "console": "internalConsole" + }, { "name": "Python: Debug bootstrapping Python install script", "type": "debugpy", diff --git a/requirements/uv.in b/requirements/uv.txt similarity index 100% rename from requirements/uv.in rename to requirements/uv.txt diff --git a/scripts/Sync-Py.ps1 b/scripts/Sync-Py.ps1 index 48a3fdb..0371a24 100644 --- a/scripts/Sync-Py.ps1 +++ b/scripts/Sync-Py.ps1 @@ -25,7 +25,7 @@ elseif ($Release) { $msg = 'release' } "Will run $msg steps" | Write-Progress -Info 'FINDING UV' | Write-Progress -$uvVersionRe = Get-Content 'requirements/uv.in' | Select-String -Pattern '^uv==(.+)$' +$uvVersionRe = Get-Content 'requirements/uv.txt' | Select-String -Pattern '^uv==(.+)$' $uvVersion = $uvVersionRe.Matches.Groups[1].value if (!(Test-Path 'bin/uv*') -or !(bin/uv --version | Select-String $uvVersion)) { $Env:CARGO_HOME = '.' @@ -72,6 +72,7 @@ bin/uv pip install --editable=scripts '*** RUNNING PRE-SYNC TASKS' | Write-Progress if ($CI) { 'SYNCING PROJECT WITH TEMPLATE' | Write-Progress + boilercore_tools elevate-pyright-warnings try {scripts/Sync-Template.ps1 -Stay} catch [System.Management.Automation.NativeCommandExitException] { git stash save --include-untracked scripts/Sync-Template.ps1 -Stay diff --git a/scripts/boilercore_tools/__main__.py b/scripts/boilercore_tools/__main__.py index 3e9d7a5..573aaaa 100644 --- a/scripts/boilercore_tools/__main__.py +++ b/scripts/boilercore_tools/__main__.py @@ -1,8 +1,10 @@ """CLI for tools.""" from collections.abc import Collection +from json import dumps from pathlib import Path from re import finditer +from sys import version_info from cyclopts import App @@ -10,6 +12,13 @@ from boilercore_tools.sync import check_compilation, escape from boilercore_tools.types import ChangeType +if version_info >= (3, 11): # noqa: UP036, RUF100 + from tomllib import loads # pyright: ignore[reportMissingImports] +else: + from toml import ( # pyright: ignore[reportMissingModuleSource, reportMissingImports] + loads, + ) + APP = App(help_format="markdown") """CLI.""" @@ -55,6 +64,19 @@ def get_actions(): log(sorted(set(actions))) +@APP.command +def elevate_pyright_warnings(): + """Elevate Pyright warnings to errors.""" + config = loads(Path("pyproject.toml").read_text("utf-8")) + pyright = config["tool"]["pyright"] + for k, v in pyright.items(): + if (rule := k).startswith("report") and (_level := v) == "warning": + pyright[rule] = "error" + Path("pyrightconfig.json").write_text( + encoding="utf-8", data=dumps(pyright, indent=2) + ) + + def log(obj): """Send object to `stdout`.""" match obj: diff --git a/scripts/boilercore_tools/sync.py b/scripts/boilercore_tools/sync.py index 6156210..0efd96f 100644 --- a/scripts/boilercore_tools/sync.py +++ b/scripts/boilercore_tools/sync.py @@ -3,15 +3,27 @@ from __future__ import annotations from dataclasses import asdict, dataclass, field -from datetime import UTC, datetime +from datetime import datetime from json import dumps, loads from pathlib import Path from re import finditer from shlex import quote, split from subprocess import run +from sys import version_info +from typing import TYPE_CHECKING from boilercore_tools.types import Dep, PythonVersion, SubmoduleInfoKind, ops +if version_info >= (3, 11): # noqa: UP036, RUF100 + from datetime import UTC # pyright: ignore[reportAttributeAccessIssue] +else: + from datetime import timezone + + UTC = timezone.utc # noqa: UP017, RUF100 + +if TYPE_CHECKING: + UTC: timezone + MINIMUM_PYTHON = "3.11" """This project's default Python version.""" diff --git a/scripts/pyproject.toml b/scripts/pyproject.toml index 5c7186f..be56e86 100644 --- a/scripts/pyproject.toml +++ b/scripts/pyproject.toml @@ -13,6 +13,7 @@ dependencies = [ "dulwich==0.22.1", "ipython==8.25.0", "pipx==1.6.0", + "toml==0.10.2 ; python_version < '3.11'", ] [project.scripts] "boilercore_tools" = "boilercore_tools.__main__:main" diff --git a/src/boilercore/hashes.py b/src/boilercore/hashes.py index 1325b68..7cfc216 100644 --- a/src/boilercore/hashes.py +++ b/src/boilercore/hashes.py @@ -40,7 +40,7 @@ def cached_function(*args, *kwds): ) -def freeze(v: Hashable | Freezable) -> Hashable: +def freeze(v: Hashable | Freezable | Any) -> Hashable: """Make value hashable.""" match v: case Hashable():