Skip to content

Donovan-Eral/python-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

7 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Modern Python Template

Python uv Ruff License

A fast, modern Python project template using the latest Rust-based tooling for maximum developer productivity.

✨ Features

  • πŸš€ uv - Lightning-fast Python package manager
  • πŸ”§ ruff - Extremely fast Python linter and formatter
  • πŸ§ͺ ty - Rust-based type checker (by Astral)
  • 🐳 Docker support with live reload for development
  • ⚑ GitHub Actions CI/CD with separate lint/typecheck/test workflows
  • πŸ“‹ just for task automation
  • 🎯 VS Code integration with recommended extensions
  • πŸ”’ Python 3.12+ - Modern Python features

πŸš€ Quick Start

Using this template

  1. Click "Use this template" on GitHub or clone:

    git clone <your-repo-url>
    cd <your-project>
  2. Install dependencies:

    just install
  3. Run the application:

    just run
  4. Customize for your project:

    • Update pyproject.toml with your project details
    • Rename/modify main.py
    • Update this README

πŸ“‹ Available Commands

Install just for task automation:

# Development
just install          # Install dependencies
just run              # Run the application
just test             # Run tests with pytest
just format           # Format code with ruff
just lint             # Lint code with ruff (use --fix to auto-fix)
just typecheck        # Type check with ty
just check            # Run lint + typecheck
just clean            # Clean cache files

# Docker
just build-docker     # Build Docker image
just run-docker       # Run with docker-compose (live reload)
just stop-docker      # Stop docker services

# Help
just help             # Show all available commands

πŸ› οΈ Development Setup

Prerequisites

  • Python 3.12+
  • uv (package manager)
  • just (task runner)
  • Docker (optional, for containerization)

Local Development

# Clone and setup
git clone <your-repo>
cd <your-project>
just install

# Start developing
just run              # Run locally
just test             # Run tests
just format           # Format before committing
just check            # Lint and type check

VS Code Setup

This template includes VS Code configuration:

  1. Install recommended extensions (VS Code will prompt you)
  2. Automatic formatting on save with ruff
  3. Type checking with ty/pyrefly
  4. Syntax highlighting for justfiles and TOML

🐳 Docker Development

For containerized development with live reload:

just build-docker     # Build the image
just run-docker       # Start with live reload

# Your code changes will be reflected immediately
# No need to rebuild for code changes

πŸ§ͺ Testing

This template includes pytest for testing:

# Run tests
just test

# Run tests with verbose output
just test-verbose

# Run tests with coverage
just test-cov

Add your tests in test_*.py files:

# test_main.py
def test_basic():
    """Verify pytest is working."""
    assert True

def test_your_function():
    """Test your actual code."""
    from main import your_function
    assert your_function() == expected_result

πŸ”„ CI/CD

This template includes GitHub Actions workflows:

  • Lint (lint.yml) - Fast code style checking
  • Type Check (typecheck.yml) - Type safety validation
  • Test (test.yml) - Run your test suite

All workflows run on push/PR and provide fast feedback.

πŸ“ Project Structure

.
β”œβ”€β”€ .github/
β”‚   └── workflows/           # CI/CD workflows
β”œβ”€β”€ .vscode/
β”‚   └── extensions.json      # Recommended VS Code extensions
β”œβ”€β”€ .dockerignore           # Docker ignore rules
β”œβ”€β”€ .gitignore              # Git ignore rules
β”œβ”€β”€ Dockerfile              # Container definition
β”œβ”€β”€ docker-compose.yaml     # Development container setup
β”œβ”€β”€ justfile                # Task automation
β”œβ”€β”€ main.py                 # Your application entry point
β”œβ”€β”€ pyproject.toml          # Project configuration
β”œβ”€β”€ README.md               # This file
└── uv.lock                # Dependency lock file

βš™οΈ Configuration

Python Dependencies

Add dependencies using uv:

# Add runtime dependencies
uv add requests pydantic

# Add development dependencies  
uv add --dev pytest-xdist black

# Add optional dependencies
uv add --optional web fastapi uvicorn

Then run:

just install

Code Quality

Configuration in pyproject.toml:

  • ruff: Linting and formatting rules
  • Python version: 3.12+ required

🚒 Deployment

Building for Production

# Build optimized Docker image
docker build -t your-app .

# Run in production mode
docker run -p 8000:8000 your-app

Environment Variables

Create .env file for local development:

# .env (not committed to git)
DATABASE_URL=sqlite:///local.db
DEBUG=true

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Make your changes
  4. Run quality checks: just check
  5. Commit changes: git commit -m 'Add amazing feature'
  6. Push to branch: git push origin feature/amazing-feature
  7. Open a Pull Request

πŸ“ Customization

For Your Project

  1. Update pyproject.toml:

    [project]
    name = "your-project-name"
    description = "Your project description"
    authors = [{name = "Your Name", email = "your.email@example.com"}]
  2. Rename main.py to match your application structure

  3. Add your dependencies:

    uv add requests fastapi pytest
  4. Update this README with your project-specific information

Project Structure Options

Consider organizing larger projects:

src/
└── your_package/
    β”œβ”€β”€ __init__.py
    β”œβ”€β”€ main.py
    β”œβ”€β”€ models/
    β”œβ”€β”€ api/
    └── utils/

πŸ† Why This Stack?

  • ⚑ uv: 10-100x faster than pip, handles virtual environments automatically
  • πŸ¦€ ruff: 10-100x faster than flake8/black, handles both linting and formatting
  • πŸ” ty: Rust-based type checker by the same team as uv/ruff
  • 🐳 Docker: Consistent environments, easy deployment
  • πŸ“‹ just: Simple, fast alternative to make/npm scripts
  • πŸ”„ GitHub Actions: Industry standard CI/CD

All core tools are written in Rust for maximum performance and reliability.

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • Astral for creating uv, ruff, and ty
  • Casey Rodarmor for just
  • The Rust and Python communities for amazing tooling

Happy coding! πŸŽ‰

Remember to:

  • Replace yourusername/python-template in the badge URLs with your actual GitHub username/repo
  • The workflow badges will show green βœ… once your GitHub Actions are running

About

A simple modern python template

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors