Skip to content

Commit

Permalink
Sync with template
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeNaccarato committed Jul 8, 2024
1 parent da81def commit bded831
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .copier-answers.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
16 changes: 8 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand Down
File renamed without changes.
3 changes: 2 additions & 1 deletion scripts/Sync-Py.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -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 = '.'
Expand Down Expand Up @@ -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
Expand Down
22 changes: 22 additions & 0 deletions scripts/boilercore_tools/__main__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
"""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

from boilercore_tools import add_changes
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."""

Expand Down Expand Up @@ -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:
Expand Down
14 changes: 13 additions & 1 deletion scripts/boilercore_tools/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -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."""

Expand Down
1 change: 1 addition & 0 deletions scripts/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
2 changes: 1 addition & 1 deletion src/boilercore/hashes.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand Down

0 comments on commit bded831

Please sign in to comment.