This is a minimalist Python project template configured for automatic PEP 8 compliance using Ruff and Pre-commit, plus optional VS Code setup.
pip install pre-commit ruffpre-commit installpre-commit run --all-filesAll code style and linting rules are managed in pyproject.toml. Ruff is configured to:
- Enforce PEP 8 with opinionated fixes
- Use Black-like formatting (via
ruff format) - Target Python 3.11
Hooks are defined in .pre-commit-config.yaml. This template includes:
- ruff: Lint with auto-fix
- ruff-format: Format code
- YAML/JSON/whitespace fixers for non-code hygiene
your-project/
├── pyproject.toml
├── .pre-commit-config.yaml
├── README.md
└── src/
└── main.py
Any committed code will be:
- PEP 8-compliant
- Cleanly formatted
- Automatically linted and fixed
This setup is ideal for individuals or teams aiming for consistent, clean Python code with zero manual effort.
To get the best development experience with automatic formatting and linting in real-time:
- Ruff (official extension by
Astral) – Replaces Black, isort, flake8 - Pylance – for type checking and rich intellisense
- Prettier (optional) – for non-Python files like Markdown or JSON
{
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit"
}
},
"editor.rulers": [88],
"files.autoSave": "afterDelay"
}Ensure your Python environment is selected correctly via the Command Palette (Cmd/Ctrl+Shift+P → "Python: Select Interpreter").