Skip to content
Merged
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: 4 additions & 2 deletions .github/workflows/python-app.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13"] # 3.11 is the lowest we support, since we want StrEnum
python-version: ["3.11", "3.12", "3.13", "3.14"] # 3.11 is the lowest we support, since we want StrEnum
container:
image: problemtools/githubci:latest
steps:
Expand All @@ -30,8 +30,10 @@ jobs:
run: |
python -m venv venv
venv/bin/python --version
venv/bin/pip install mypy ruff pytest
venv/bin/pip install -r requirements-dev.txt
if [ -f requirements.txt ]; then venv/bin/pip install -r requirements.txt; fi
- name: Check ruff version matches .pre-commit-config.yaml
run: venv/bin/python admin/check_ruff_version.py
- name: Lint with ruff
run: venv/bin/ruff check --output-format=github
- name: Check ruff formatting
Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.8
rev: v0.15.22
hooks:
- id: ruff
- id: ruff-format
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
all:
make -C support

test:
./run_tests.sh

builddeb:
dpkg-buildpackage -us -uc -tc -b

Expand Down
42 changes: 42 additions & 0 deletions admin/check_ruff_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Run from your venv with repo root as cwd. E.g., venv/bin/python3 admin/check_ruff_version.py
"""Fail if the installed ruff version differs from .pre-commit-config.yaml's pinned rev."""

import pathlib
import subprocess
import sys

import yaml
Comment thread
gkreitz marked this conversation as resolved.


def installed_ruff_version() -> str:
ruff = pathlib.Path(sys.executable).parent / 'ruff'
output = subprocess.check_output([ruff, '--version'], text=True)
return output.strip().split()[-1]


def precommit_ruff_rev() -> str:
with open('.pre-commit-config.yaml') as f:
config = yaml.safe_load(f)
for repo in config['repos']:
if 'ruff-pre-commit' in repo['repo']:
return repo['rev'].lstrip('v')
raise RuntimeError('ruff-pre-commit repo not found in .pre-commit-config.yaml')


def main() -> int:
installed = installed_ruff_version()
pinned = precommit_ruff_rev()
if installed != pinned:
print(
f'ruff version mismatch: installed ruff is {installed}, but '
f'.pre-commit-config.yaml pins v{pinned}. Keep requirements-dev.in '
f'and .pre-commit-config.yaml in sync.',
file=sys.stderr,
)
return 1
print(f'ruff version {installed} matches .pre-commit-config.yaml')
return 0


if __name__ == '__main__':
sys.exit(main())
13 changes: 4 additions & 9 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,7 @@ license = "MIT"
keywords = ["kattis", "problemtools", "icpc", "clics"]
requires-python = ">= 3.11"

dependencies = [
"colorlog",
"nh3",
"PyYAML",
"plasTeX>=3.0",
"pydantic>=2.11",
"checktestdata>=2026.7.1",
]
dynamic = [ "version" ]
dynamic = [ "version", "dependencies" ]

[project.scripts]
verifyproblem = "problemtools.verifyproblem:main"
Expand All @@ -40,6 +32,9 @@ include-package-data = true
[tool.setuptools.packages.find]
include = ["problemtools", "problemtools.*"]

[tool.setuptools.dynamic]
dependencies = {file = ["requirements.txt"]}

[tool.setuptools_scm]
version_file = "problemtools/_version.py"
local_scheme = "no-local-version"
Expand Down
5 changes: 5 additions & 0 deletions requirements-dev.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# ruff 0.16 adds a ton of new default rules that our codebase doesn't yet pass;
# holding at the latest 0.15.x release until we've triaged those.
ruff==0.15.22
mypy
pytest
235 changes: 235 additions & 0 deletions requirements-dev.txt

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions run_tests.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/bash
set -e

cd "$(dirname "$0")"

venv/bin/pip install -q -r requirements-dev.txt
if [ -f requirements.txt ]; then venv/bin/pip install -q -r requirements.txt; fi
venv/bin/python admin/check_ruff_version.py
venv/bin/ruff check .
venv/bin/ruff format --check .
venv/bin/pytest
venv/bin/mypy --non-interactive --config-file mypy.ini -p problemtools