Skip to content

Embed code snippets for README from executable examples #1055

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
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
19 changes: 19 additions & 0 deletions .github/workflows/shared.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ name: Shared Checks
on:
workflow_call:

permissions:
contents: read

jobs:
pre-commit:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -46,3 +49,19 @@ jobs:
- name: Run pytest
run: uv run --frozen --no-sync pytest
continue-on-error: true

readme-snippets:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- uses: astral-sh/setup-uv@v5
with:
enable-cache: true
version: 0.7.2

- name: Install dependencies
run: uv sync --frozen --all-extras --python 3.10

- name: Check README snippets are up to date
run: uv run --frozen scripts/update_readme_snippets.py --check
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ repos:
types: [python]
language: system
pass_filenames: false
exclude: ^README\.md$
- id: pyright
name: pyright
entry: uv run pyright
Expand All @@ -36,3 +37,9 @@ repos:
language: system
files: ^(pyproject\.toml|uv\.lock)$
pass_filenames: false
- id: readme-snippets
name: Check README snippets are up to date
entry: uv run scripts/update_readme_snippets.py --check
language: system
files: ^(README\.md|examples/.*\.py|scripts/update_readme_snippets\.py)$
pass_filenames: false
7 changes: 6 additions & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,12 @@ uv run ruff check .
uv run ruff format .
```

7. Submit a pull request to the same branch you branched from
7. Update README snippets if you modified example code:
```bash
uv run scripts/update_readme_snippets.py
```

8. Submit a pull request to the same branch you branched from

## Code Style

Expand Down
Loading
Loading