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
13 changes: 13 additions & 0 deletions .cursor/rules/docs.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
description: "Documentation conventions"
globs:
- "docs/**/*.md"
- "mkdocs.yaml"
alwaysApply: false
---

# Documentation Rules
- Write docs in Markdown with clear headings and code examples.
- Update `mkdocs.yaml` navigation when adding new docs.
- Keep `README.md` concise, and move long explanations to `/docs`.
- Use Python code fences (```python … ```) in examples.
13 changes: 13 additions & 0 deletions .cursor/rules/pydantic-usage.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
description: "Conventions for using Pydantic models and settings"
globs:
- "**/*.py"
alwaysApply: false
---

# Pydantic Rules
- Use `pydantic.BaseModel` for request/response schemas.
- For configuration, use `pydantic_settings.BaseSettings` (v2).
- Always provide default values or use `...` for required fields.
- Use model validators (`@field_validator`, `@model_validator`) instead of custom init logic.
- Keep models small and focused on one purpose.
12 changes: 12 additions & 0 deletions .cursor/rules/python-run.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
description: "Use `uv run` for running Python code instead of raw python3"
globs:
- "**/*.py"
alwaysApply: true
---

# Running Python code
- **Do not** run `python3 -c` directly.
- Always invoke Python code using `uv run python <script>` or `uv run <module>` when executing project scripts.
- Use the `uv` environment so that dependencies from `uv.lock` are respected.
- This applies to both interactive code execution and testing.
15 changes: 15 additions & 0 deletions .cursor/rules/python-style.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
---
description: "Follow project style guidelines for Python code"
globs:
- "**/*.py"
alwaysApply: true
---

# Python Coding Rules
- Use python 3.12 conventions: use `type | None` instead of `Optional` etc
- Use type hints everywhere (PEP 484).
- Use snake_case for functions and variables, PascalCase for classes.
- Avoid unused imports.
- Use `async`/`await` where appropriate.
- Always keep functions small and composable.
- Avoid using hasattr at all costs, it's not safe
16 changes: 16 additions & 0 deletions .cursor/rules/tests.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
---
description: "Testing guidelines"
globs:
- "test/**/*.py"
alwaysApply: false
---

# Testing Guidelines
- Use `pytest` with descriptive test function names.
- Prefer fixtures over global state.
- For async code, use `pytest-asyncio`.
- Ensure test coverage for:
- Pydantic model validation
- Env config via `BaseSettings`
- Error cases and edge cases
- Run tests with `uv run pytest test`.
11 changes: 11 additions & 0 deletions .cursor/rules/uv-deps.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
description: "Dependency management with uv"
globs:
- "pyproject.toml"
- "uv.lock"
alwaysApply: false
---

# Dependency Management
- Pin versions in `pyproject.toml` for reproducibility.
- Run `uv pip check` to validate the dependency tree.
54 changes: 54 additions & 0 deletions .github/workflows/build-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
name: Build GitHub Pages
on:
push:
branches:
- main
paths:
- 'docs/**'
- 'mkdocs.yml'
- 'pelinker/**' # Check this path
workflow_dispatch:

permissions:
contents: write
pages: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v5
with:
fetch-depth: 0

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.10.12"
- name: Install dependencies
run: |
uv sync --extra docs
- name: Build site
run: |
uv run mkdocs build --site-dir _site
- name: Upload Pages artifact
uses: actions/upload-pages-artifact@v3
with:
path: _site

deploy:
needs: build
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.10.12"
- name: Install dependencies (including dev)
run: uv sync --extra dev --no-install-project
- name: Run pre-commit
run: uv run pre-commit run --all-files
35 changes: 35 additions & 0 deletions .github/workflows/pypi-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Upload Python Package to PyPI

on:
release:
types: [published]

permissions:
contents: read

jobs:
pypi-publish:
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/pelinker
permissions:
id-token: write

steps:
- uses: actions/checkout@v5

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install uv
uses: astral-sh/setup-uv@v7
with:
version: "0.10.12"
- name: Build and publish
run: |
uv build
uv publish
env:
UV_PUBLISH_TOKEN: ${{ secrets.PYPI_API_TOKEN }}
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ fail_fast: false
repos:
# Python linting and formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.14.14
rev: v0.15.7
hooks:
- id: ruff-check
args: [--fix, --ignore, E722]
Expand Down
Loading