Skip to content

Commit 1ca93b5

Browse files
committed
Initial project setup with linting, testing, and git hooks
0 parents  commit 1ca93b5

File tree

9 files changed

+185
-0
lines changed

9 files changed

+185
-0
lines changed

.gitignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Python
2+
__pycache__/
3+
*.py[cod]
4+
5+
# Virtual environments
6+
venv/
7+
.venv/
8+
9+
# Testing & Coverage
10+
.pytest_cache/
11+
.coverage/
12+
13+
# Type checking & Linting
14+
.mypy_cache/
15+
.ruff_cache/
16+
17+
# IDE
18+
.vscode/
19+
.idea/
20+
*.swp
21+
22+
# macOS
23+
.DS_Store

.pre-commit-config.yaml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
repos:
2+
- repo: https://github.com/pre-commit/pre-commit-hooks
3+
rev: v4.4.0
4+
hooks:
5+
- id: trailing-whitespace
6+
- id: end-of-file-fixer
7+
- id: check-yaml
8+
- id: check-added-large-files
9+
- id: check-merge-conflict
10+
- id: debug-statements
11+
- id: check-docstring-first
12+
13+
- repo: local
14+
hooks:
15+
- id: check-bare-todos
16+
name: Check for bare TODOs
17+
entry: '(TODO|FIXME|XXX)(?!.*:)'
18+
language: pygrep
19+
files: \.(py|md|txt|yaml|yml)$
20+
exclude: ^\.pre-commit-config\.yaml$
21+
description: 'Prevent bare TODOs without context (use "TODO: description" instead)'
22+
23+
- repo: https://github.com/astral-sh/ruff-pre-commit
24+
rev: v0.1.6
25+
hooks:
26+
- id: ruff
27+
args: [--fix]
28+
- id: ruff-format
29+
30+
- repo: https://github.com/pre-commit/mirrors-mypy
31+
rev: v1.5.1
32+
hooks:
33+
- id: mypy
34+
additional_dependencies: [pytest]
35+
args: [--strict]

Makefile

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
.PHONY: help install install-dev check-format fix-format check-lint fix-lint check-type check-all fix-all test test-cov clean pre-commit
2+
3+
help: ## Show this help message
4+
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
5+
6+
# Install dependencies
7+
install:
8+
pip install -r requirements.txt
9+
10+
install-dev:
11+
pip install -r requirements.txt
12+
pip install -r requirements-dev.txt
13+
pre-commit install
14+
15+
# Check code quality
16+
check-format:
17+
ruff format --check --diff .
18+
19+
check-lint:
20+
ruff check .
21+
22+
check-type:
23+
mypy --strict .
24+
25+
check-all:
26+
make check-format
27+
make check-lint
28+
make check-type
29+
30+
# Fix code quality issues
31+
fix-format:
32+
ruff format .
33+
34+
fix-lint:
35+
ruff check --fix .
36+
37+
fix-all:
38+
make fix-format
39+
make fix-lint
40+
41+
# Run tests
42+
test:
43+
pytest
44+
45+
test-cov:
46+
pytest --cov=lib --cov-report=html --cov-report=term-missing --cov-report=xml --cov-fail-under=100
47+
48+
# Clean up generated files
49+
clean:
50+
find . -type f -name "*.pyc" -delete
51+
find . -type d -name "__pycache__" -delete
52+
find . -type d -name "*.egg-info" -exec rm -rf {} +
53+
rm -rf .coverage/ .pytest_cache/ .mypy_cache/
54+
55+
# Run pre-commit hooks
56+
pre-commit:
57+
pre-commit run --all-files

README.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Python Personal Scripts
2+
3+
Personal Python scripts and utilities.
4+
5+
## Setup
6+
7+
```bash
8+
# Install dependencies
9+
make install-dev
10+
11+
# Run code quality checks
12+
make check-all
13+
14+
# Fix formatting and linting issues
15+
make fix-all
16+
17+
# Run tests (lib/ directory only)
18+
make test-cov
19+
```
20+
21+
## Structure
22+
23+
- `lib/` - Shared library modules (tested with 100% coverage)
24+
- `scripts/` - Executable scripts (not tested)
25+
- `tests/` - Test files for lib/ modules

lib/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
"""Shared library modules for personal scripts."""

pyproject.toml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# Ruff configuration
2+
[tool.ruff]
3+
line-length = 88
4+
target-version = "py312"
5+
6+
[tool.ruff.lint]
7+
select = ["E", "W", "F", "I"] # Basic errors, warnings, pyflakes, import sorting
8+
9+
[tool.ruff.lint.isort]
10+
known-first-party = ["lib"]
11+
12+
# mypy configuration
13+
[tool.mypy]
14+
python_version = "3.12"
15+
disallow_untyped_defs = true
16+
warn_unused_ignores = true
17+
18+
# pytest configuration
19+
[tool.pytest.ini_options]
20+
testpaths = ["tests"]
21+
addopts = ["--cov=lib", "--cov-report=html", "--cov-report=term-missing", "--cov-report=xml", "--cov-fail-under=100"]
22+
23+
# Coverage configuration
24+
[tool.coverage.run]
25+
data_file = ".coverage/data"
26+
27+
[tool.coverage.html]
28+
directory = ".coverage/htmlcov"
29+
30+
[tool.coverage.xml]
31+
output = ".coverage/coverage.xml"
32+
33+
[tool.coverage.report]
34+
fail_under = 100
35+
include = ["lib/*"]

requirements-dev.txt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# Development dependencies
2+
ruff>=0.1.0
3+
mypy>=1.5.0
4+
pre-commit>=3.0.0
5+
6+
# Testing
7+
pytest>=7.0.0
8+
pytest-cov>=4.0.0

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Add your project dependencies here

scripts/process-amex.py

Whitespace-only changes.

0 commit comments

Comments
 (0)