diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0f31714a..8044d3d4 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,17 +1,17 @@ repos: # Hooks that are run everywhere - repo: https://github.com/biomejs/pre-commit - rev: v2.4.6 + rev: v2.4.7 hooks: - id: biome-format # Hooks that are run for scripts - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.16.2 + rev: v2.19.0 hooks: - id: pyproject-fmt files: ^scripts/pyproject\.toml$ - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.5 + rev: v0.15.6 hooks: - id: ruff-check args: [--fix, --exit-non-zero-on-fix] diff --git a/scripts/src/scverse_template_scripts/cruft_prs.py b/scripts/src/scverse_template_scripts/cruft_prs.py index 5950e421..91345f3b 100644 --- a/scripts/src/scverse_template_scripts/cruft_prs.py +++ b/scripts/src/scverse_template_scripts/cruft_prs.py @@ -10,7 +10,7 @@ import os import sys from collections.abc import Iterable -from dataclasses import KW_ONLY, InitVar, dataclass, field +from dataclasses import KW_ONLY, dataclass, field from glob import glob from pathlib import Path from subprocess import run @@ -76,7 +76,6 @@ class GitHubConnection: """API connection to a GitHub user (e.g. scverse-bot)""" - _login: InitVar[str] token: str | None = field(repr=False, default=None) _: KW_ONLY email: str | None = field(default=None) @@ -85,9 +84,10 @@ class GitHubConnection: user: NamedUser = field(init=False) sig: Actor = field(init=False) - def __post_init__(self, _login: str) -> None: + def __post_init__(self) -> None: + assert self.token.startswith("github_pat_") self.gh = Github(auth=Auth.Token(self.token) if self.token else None) - self.user = cast("NamedUser", self.gh.get_user(_login)) + self.user = cast("NamedUser", self.gh.get_user()) if self.email is None: self.email = self.user.email self.sig = Actor(self.login, self.email) diff --git a/scripts/tests/test_cruft.py b/scripts/tests/test_cruft.py index e76f84ec..bccbff18 100644 --- a/scripts/tests/test_cruft.py +++ b/scripts/tests/test_cruft.py @@ -29,7 +29,9 @@ def bot_con() -> GitHubConnection: """Connect to the scverse-bot github account. Make sure to use only a readonly-token to not destroy anything.""" token = os.environ["SCVERSE_BOT_READONLY_GITHUB_TOKEN"] - return GitHubConnection("scverse-bot", token, email="108668866+scverse-bot@users.noreply.github.com") + con = GitHubConnection(token, email="108668866+scverse-bot@users.noreply.github.com") + assert con.login == "scverse-bot" + return con @pytest.fixture diff --git a/{{cookiecutter.project_name}}/.pre-commit-config.yaml b/{{cookiecutter.project_name}}/.pre-commit-config.yaml index e5325f76..cac19ee3 100644 --- a/{{cookiecutter.project_name}}/.pre-commit-config.yaml +++ b/{{cookiecutter.project_name}}/.pre-commit-config.yaml @@ -7,16 +7,16 @@ default_stages: minimum_pre_commit_version: 2.16.0 repos: - repo: https://github.com/biomejs/pre-commit - rev: v2.4.6 + rev: v2.4.7 hooks: - id: biome-format exclude: ^\.cruft\.json$ # inconsistent indentation with cruft - file never to be modified manually. - repo: https://github.com/tox-dev/pyproject-fmt - rev: v2.16.2 + rev: v2.19.0 hooks: - id: pyproject-fmt - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.15.5 + rev: v0.15.6 hooks: - id: ruff-check types_or: [python, pyi, jupyter]