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
22 changes: 22 additions & 0 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
## Summary

<!-- What does this PR change and why? -->

## Related Issues

<!-- e.g. Closes #123 -->

## Type of Change

- [ ] Bug fix
- [ ] New feature
- [ ] Refactor / cleanup
- [ ] Documentation
- [ ] Build / CI / tooling

## Checklist

- [ ] `just lint` passes
- [ ] `just test` passes
- [ ] Tests added or updated for the change
- [ ] `README.md` / `CHANGELOG.md` updated if needed
18 changes: 13 additions & 5 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,35 @@ on:
pull_request:
branches: [ main ]

permissions:
contents: read
pull-requests: read

jobs:
code-check-and-unit-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- name: Setup Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
fetch-depth: 0 # gitleaks needs commit history to scan the PR range
- name: Setup just
uses: extractions/setup-just@v3
- name: Install uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9
uses: astral-sh/setup-uv@v7
with:
enable-cache: true
version: ">=0.11,<0.12"
- name: Check gitleaks
uses: gitleaks/gitleaks-action@v3
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITLEAKS_ENABLE_COMMENTS: false
- name: Setup environment
run: |
just sync
- name: Lint
run: |
just lint
just ci-lint
- name: Unit tests
run: |
just test
6 changes: 6 additions & 0 deletions .markdownlint-cli2.jsonc
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
// Files excluded from markdown linting (glob syntax)
"ignores": [
".github/pull_request_template.md"
]
}
3 changes: 2 additions & 1 deletion Brewfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
brew "gitleaks"
brew "just"
brew "uv"
brew "uv"
33 changes: 24 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# PyPricecharting API Client ![](https://github.com/ahcode0919/pypricecharting/actions/workflows/ci.yml/badge.svg?branch=main)
# PyPricecharting API Client ![](https://github.com/ahcode0919/pypricecharting/actions/workflows/python.yml/badge.svg?branch=main)
[![gitleaks](https://img.shields.io/badge/protected%20by-gitleaks-blue)](https://github.com/gitleaks/gitleaks)

Pricecharting API Client written in Python

Expand All @@ -10,8 +11,11 @@ Project supports local development and VSCode Dev container development

Note: Project uses `uv` and `just` to manage project configuration and commands

* Install dependencies via Homebrew - `brew bundle install`
* Sync project - `just sync`
* Install `just` - `brew install just`
* Set up project - `just setup`
* Installs Homebrew dependencies (`gitleaks`, `just`, `uv`)
* Installs `prek` git hooks
* Syncs project dependencies

### VS Code Dev Container

Expand All @@ -23,12 +27,23 @@ Note: Project uses `uv` and `just` to manage project configuration and commands

## Project Commands

* Local
* `just lint` - lint project files
* Dev container
* `just lint` - lint and stylecheck project files
* Run unit tests: `just test`
* Install dependency: `uv add {package}`
* `just setup` - install tools and git hooks, then sync dependencies
* `just sync` - sync project dependencies
* `just lint` - type check (`ty`), lint and format (`ruff`), and spellcheck (`codespell`). Fixes files in place
* `just ci-lint` - same checks as `just lint`, without modifying files
* `just test` - run unit tests
* `just prek` - run all pre-commit hooks
* `just git-leaks` - scan staged changes for secrets
* `uv add {package}` - install a dependency

### Pre-commit Hooks

`prek` runs these hooks on commit (configured in `prek.toml`):

* Built-in checks: trailing whitespace, end of file, large files, YAML, and JSON
* `just ci-lint`
* `just test`
* `gitleaks` secret scan of staged changes

## Usage

Expand Down
16 changes: 15 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,8 +1,22 @@
ci-lint:
uv run ty check
uv run ruff check .
uv run ruff format --check .
uv run codespell
git-leaks:
gitleaks git --pre-commit --staged --redact
lint:
uv run ty check
uv run ruff check . --fix
uv run ruff format .
uv run codespell
prek:
uv run prek
setup:
brew bundle install
uv run prek install
just sync
sync:
uv sync --all-groups
test:
uv run pytest
uv run pytest
42 changes: 42 additions & 0 deletions prek.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Configuration file for `prek`, a git hook framework written in Rust.
# See https://prek.j178.dev for more information.
#:schema https://www.schemastore.org/prek.json

[[repos]]
repo = "builtin"
hooks = [
{ id = "trailing-whitespace" },
{ id = "end-of-file-fixer" },
{ id = "check-added-large-files" },
{ id = "check-yaml" },
{
id = "check-json",
exclude = "devcontainer.json"
}
]

[[repos]]
repo = "local"
hooks = [
{
id = "ci-lint",
name = "lint codebase",
language = "system",
entry = "just ci-lint",
pass_filenames = false
},
{
id = "unit-tests",
name = "unit tests",
language = "system",
entry = "just test",
pass_filenames = false
},
{
id = "git-leaks",
name = "git leaks",
language = "system",
entry = "gitleaks git --pre-commit --staged --redact",
pass_filenames = false
}
]
17 changes: 13 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,32 +1,38 @@
[project]
name = "example"
name = "pypricecharting"
description = "Python PriceCharting API Client"
version = "0.0.1"
requires-python = ">=3.14"

dependencies = []

[build-system]
requires = ["uv_build>=0.11.32,<0.12.0"]
build-backend = "uv_build"

[dependency-groups]
dev = [
"codespell>=2.4.3",
"prek>=0.5.10",
"pytest",
"pytest-cov",
"ruff>=0.16.0",
"ty>=0.0.96",
]

[tool.codespell]
# Product names used in PriceCharting's example data.
ignore-words-list = "gameboy"


[tool.pytest.ini_options]
pythonpath = ["."]
addopts = "--cov=src --cov-report=term-missing --cov-fail-under 98"

[tool.ruff]
line-length = 100
target-version = "py312"

[tool.ruff.lint]
select = ["E", "F", "W", "I", "N", "D"] # Choose your rule categories
select = ["B", "E", "F", "W", "I", "N", "PT", "D", "UP", "RUF", "SIM"] # Choose your rule categories
ignore = ["D100", "D104", "D211", "D203", "D213", "D400", "D401", "D415"]
extend-ignore = ["E501"] # Line too long (handled by formatter)

Expand All @@ -35,3 +41,6 @@ extend-ignore = ["E501"] # Line too long (handled by formatter)

[tool.ruff.format]
quote-style = "double"

[tool.uv]
required-version = ">=0.11,<0.12"
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion tests/test_hello_world.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from src.hello_world import hello_world
from pypricecharting.hello_world import hello_world


def test_hello_world():
Expand Down
Loading
Loading