Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -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]
Expand Down
8 changes: 4 additions & 4 deletions scripts/src/scverse_template_scripts/cruft_prs.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
4 changes: 3 additions & 1 deletion scripts/tests/test_cruft.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions {{cookiecutter.project_name}}/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
Loading