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
17 changes: 15 additions & 2 deletions .github/workflows/pre-commit-hooks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,18 @@ jobs:
with:
fetch-depth: 0

# Set up Python
# Set up Python (must match requires-python in pyproject.toml)
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'

# Verify Python version matches project requirements
- name: Verify Python version
run: |
python --version
python -c "import sys; assert sys.version_info >= (3, 12), f'Python 3.12+ required, got {sys.version}'"

# Set up a Python virtual environment
- name: Set up Python and Virtual Environment
run: |
Expand All @@ -48,7 +54,14 @@ jobs:
pre-commit install

# Run pre-commit hooks on all files
- name: Run pre-commit
# This includes:
# - Python syntax validation (check-ast)
# - Code formatting (ruff-format)
# - Linting and import sorting (ruff)
# - Python version compatibility checks (pyupgrade for Python 3.12+)
# - YAML/JSON validation
# - Trailing whitespace and end-of-file fixes
- name: Run pre-commit hooks
run: |
source venv/bin/activate
pre-commit run --all-files --show-diff-on-failure
12 changes: 12 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ repos:
# Checks YAML files for syntax errors
- id: check-json
# Checks JSON files for syntax errors
- id: check-ast
name: "Check Python syntax (AST validation)"
# Validates that Python files have valid syntax

# Ruff hooks for Python linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
Expand All @@ -31,6 +34,15 @@ repos:
name: "Linting and import sorting"
args: ["--fix"]

# Pyupgrade: Check and fix Python version incompatibilities and outdated syntax
- repo: https://github.com/asottile/pyupgrade
rev: v3.15.2
hooks:
- id: pyupgrade
name: "Upgrade syntax for Python 3.12+"
args: [--py312-plus]
# Auto-fixes outdated syntax to Python 3.12+ compatible code

# Conventional pre-commit hooks for commit messages
- repo: https://github.com/compilerla/conventional-pre-commit
rev: v4.0.0
Expand Down
7 changes: 2 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,6 @@ classifiers = [
"Intended Audience :: Developers",
"License :: OSI Approved :: MIT License",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3.12",
"Topic :: Software Development :: Libraries :: Python Modules",
"Topic :: Software Development :: Quality Assurance",
Expand Down Expand Up @@ -160,7 +157,7 @@ watchflow = "src.main:app"

[tool.black]
line-length = 88
target-version = ['py39']
target-version = ['py312']
include = '\.pyi?$'
extend-exclude = '''
/(
Expand All @@ -183,7 +180,7 @@ line_length = 88
known_first_party = ["src"]

[tool.mypy]
python_version = "3.9"
python_version = "3.12"
warn_return_any = true
warn_unused_configs = true
disallow_untyped_defs = true
Expand Down
Loading