Skip to content

Commit 30c00ae

Browse files
[feat] Set up uv and precommit (#2)
1 parent 369720f commit 30c00ae

7 files changed

Lines changed: 305 additions & 0 deletions

File tree

.editorconfig

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
root = true
2+
3+
[*]
4+
charset = utf-8
5+
end_of_line = lf
6+
insert_final_newline = true
7+
trim_trailing_whitespace = true
8+
9+
[*.py]
10+
indent_style = space
11+
indent_size = 4
12+
13+
[*.json]
14+
indent_style = space
15+
indent_size = 2

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
uv.lock linguist-generated=true

.github/workflows/pre-commit.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: ["main"]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v6
13+
14+
- name: Set up uv
15+
uses: astral-sh/setup-uv@v7
16+
with:
17+
python-version: "3.12"
18+
19+
- name: Install dev dependencies
20+
run: uv sync --dev
21+
22+
- name: Run pre-commit (all files)
23+
run: uv run pre-commit run --all-files

.pre-commit-config.yaml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
minimum_pre_commit_version: "3.0.0"
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/pre-commit-hooks
5+
rev: v6.0.0
6+
hooks:
7+
- id: check-added-large-files
8+
- id: check-ast
9+
- id: check-json
10+
- id: check-merge-conflict
11+
- id: debug-statements
12+
- id: end-of-file-fixer
13+
- id: trailing-whitespace
14+
15+
- repo: https://github.com/astral-sh/ruff-pre-commit
16+
rev: v0.14.14
17+
hooks:
18+
- id: ruff
19+
args: ["--fix", "--exit-non-zero-on-fix"]
20+
- id: ruff-format
21+
22+
# Prettier runs via a local Node hook so we can pin to the latest Prettier.
23+
- repo: local
24+
hooks:
25+
- id: prettier-json
26+
name: prettier (json)
27+
language: node
28+
additional_dependencies: ["prettier@3.8.1"]
29+
entry: prettier --write
30+
files: "\\.json$"

README.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# gallery
2+
3+
Scripts-first repo with:
4+
5+
- `pre-commit` for consistent checks on commit
6+
- Ruff for Python linting/formatting
7+
- Prettier for JSON formatting
8+
9+
## Setup (local)
10+
11+
Create a virtualenv and install dev tools:
12+
13+
```bash
14+
uv venv
15+
source .venv/bin/activate
16+
uv sync --dev
17+
```
18+
19+
Install git hooks:
20+
21+
```bash
22+
pre-commit install
23+
```
24+
25+
Run all hooks:
26+
27+
```bash
28+
pre-commit run --all-files
29+
```
30+
31+
Note: `pre-commit` will also set up an isolated Node environment to run Prettier.
32+
33+
## Layout
34+
35+
- `scripts/`: runnable scripts

pyproject.toml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
[project]
2+
name = "gallery"
3+
version = "0.0.0"
4+
description = "Metadata repo for Streamlit."
5+
readme = "README.md"
6+
requires-python = ">=3.12"
7+
dependencies = []
8+
9+
[dependency-groups]
10+
dev = ["pre-commit", "ruff"]
11+
12+
[tool.ruff]
13+
target-version = "py312"
14+
line-length = 100
15+
16+
[tool.ruff.lint]
17+
select = ["E", "F", "I", "B", "UP", "SIM", "RUF"]
18+
ignore = ["E501"]
19+
20+
[tool.ruff.format]
21+
quote-style = "double"
22+
indent-style = "space"
23+
line-ending = "auto"

uv.lock

Lines changed: 178 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)