Add repo config and python project template

This commit is contained in:
jay
2026-11-09 12:36:39 -05:00
commit 041a9f3943
18 changed files with 498 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
__pycache__/
*.pyc
.pytest_cache/
.pylint.d/
+22
View File
@@ -0,0 +1,22 @@
[MASTER]
fail-under=10.0
py-version=3.12
[MESSAGES CONTROL]
disable=raw-checker-failed,
bad-inline-option,
locally-disabled,
file-ignored,
suppressed-message,
useless-suppression,
deprecated-pragma,
use-symbolic-message-instead
[BASIC]
no-docstring-rgx=^_
[REPORTS]
reports=no
[FORMAT]
max-line-length=100
+17
View File
@@ -0,0 +1,17 @@
# {{PKG}}
## Testing
- Baseline: `just test` (wraps `pipenv run pytest`)
- Single test: `pipenv run pytest tests/test_file.py::test_name`
## Git
- Push to origin after every commit.
## Quality gate
- Run `just ci` (fmt-check, lint, test) before staging any changes.
- The pre-commit hook is versioned at `hooks/pre-commit`; install it with `just install-hooks`. It re-runs `just ci` at commit time and fails closed if `just` is unavailable.
- Tool config: `.pylintrc` (pylint), `pyproject.toml` (black, isort). Fix mode: `just fmt`.
## Layout
- Flat layout, no packaging step: root `conftest.py` exists only to put the repo root on sys.path for tests.
- Application entrypoints belong in a `bin/` directory at the repo root.
+16
View File
@@ -0,0 +1,16 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
[dev-packages]
pytest = "*"
pylint = "*"
black = "*"
isort = "*"
autoflake = "*"
[requires]
python_version = "3.12"
+1
View File
@@ -0,0 +1 @@
"""Put the repo root on sys.path for tests (flat layout, no packaging step)."""
+10
View File
@@ -0,0 +1,10 @@
#!/bin/sh
# Quality gate: run all checks before allowing a commit (see AGENTS.md).
if command -v just >/dev/null 2>&1; then
exec just ci
fi
if [ -x "$HOME/.cargo/bin/just" ]; then
exec "$HOME/.cargo/bin/just" ci
fi
echo "pre-commit: 'just' not found; cannot run the ci gate" >&2
exit 1
+27
View File
@@ -0,0 +1,27 @@
# Run the full test suite
test:
pipenv run pytest
# Auto-fix imports and formatting (autoflake, isort, black)
fmt:
pipenv run autoflake --recursive --remove-all-unused-imports --remove-unused-variables --in-place {{PKG}} tests conftest.py
pipenv run isort {{PKG}} tests conftest.py
pipenv run black {{PKG}} tests conftest.py
# Verify imports and formatting without modifying files
fmt-check:
pipenv run autoflake --recursive --check --remove-all-unused-imports --remove-unused-variables {{PKG}} tests conftest.py
pipenv run isort --check-only --diff {{PKG}} tests conftest.py
pipenv run black --check --diff {{PKG}} tests conftest.py
# Lint package and tests (python -m so the repo root lands on sys.path)
lint:
pipenv run python -m pylint {{PKG}} tests conftest.py
# Install the versioned pre-commit hook into .git/hooks
install-hooks:
cp hooks/pre-commit .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit
# All quality checks; must be green before staging (see AGENTS.md)
ci: fmt-check lint test
+13
View File
@@ -0,0 +1,13 @@
[tool.black]
line-length = 100
target_version = ['py312']
include = '\.pyi?$'
[tool.isort]
profile = "black"
src_paths = ["."]
line_length = 100
indent = ' '
multi_line_output = 3
include_trailing_comma = true
known_first_party = ["{{PKG}}"]