Skip to content

Latest commit

 

History

9 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🧰 Python Starter Template

This is a minimalist Python project template configured for automatic PEP 8 compliance using Ruff and Pre-commit, plus optional VS Code setup.

🚀 Quickstart

1. Install dependencies

pip install pre-commit ruff

2. Install Git pre-commit hooks

pre-commit install

3. Run pre-commit manually (optional, recommended for first run)

pre-commit run --all-files

🔧 Configuration

Ruff

All 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

Pre-commit Hooks

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

📁 Project Structure

your-project/
├── pyproject.toml
├── .pre-commit-config.yaml
├── README.md
└── src/
    └── main.py

✅ Result

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.


🧩 (Optional) VS Code / Cursor Setup

To get the best development experience with automatic formatting and linting in real-time:

Required Extensions

  • 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

Suggested settings.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").

About

Minimal Python template with auto PEP 8 compliance via Ruff & Pre-commit, plus optional VS Code setup.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages