A modern, production-ready Python project template with best practices for development, testing, and deployment.
- Modern Python: Configured for Python 3.11+
- Code Quality Tools:
- Black: Uncompromising code formatter
- Ruff: Fast Python linter
- isort: Import sorter
- pre-commit: Git hooks for code quality checks
- Project Structure: Organized directory layout for maintainable code
- FastAPI Integration: Ready for API development
- Database Support: PostgreSQL integration with psycopg
- Testing: Pytest configuration for robust testing
- Dependency Management: Modern Python dependency management
python-ops-starter/
├── .git/ # Git repository
├── .venv/ # Virtual environment (not committed)
├── configs/ # Configuration files
│ ├── postgresql_config.sql # PostgreSQL database configuration
│ └── pytest.ini # Pytest configuration
├── docs/ # Documentation
│ ├── api_guidelines.md # API development guidelines
│ ├── docker_guidelines.md # Docker containerization guidelines
│ ├── documentation_update_procedure.md # Documentation procedures
│ ├── flyio_deployment.md # Fly.io deployment instructions
│ ├── git_guidelines.md # Git workflow guidelines
│ ├── integration_guidelines.md # API integration guidelines
│ ├── ml_guidelines.md # Machine learning guidelines
│ └── uv_setup.md # UV package manager setup
├── scripts/ # Utility scripts
├── src/ # Source code
│ ├── api/ # API endpoints and routes
│ ├── db/ # Database models and connections
│ └── models/ # Data models and schemas
├── tests/ # Test files
│ └── test_main.py # Main test file
├── .black # Black configuration
├── .gitignore # Git ignore file
├── .isort.cfg # isort configuration
├── .pre-commit-config.yaml # pre-commit configuration
├── .python-version # Python version specification
├── .ruff.toml # Ruff configuration
├── hello.py # Example file
├── LICENSE # MIT License
├── pyproject.toml # Project configuration
├── README.md # This file
└── uv.lock # UV dependency lock file
- Python 3.11 or higher
- Git
-
Clone this repository:
git clone https://github.com/yourusername/python-ops-starter.git my-new-project cd my-new-project
-
Create and activate a virtual environment:
python -m venv .venv source .venv/bin/activate # On Windows: .venv\Scripts\activate
-
Install dependencies:
pip install -e .
-
Install pre-commit hooks:
pre-commit install
This template includes several tools to maintain code quality:
- Black: Formats code automatically
- isort: Sorts imports
- Ruff: Lints code and catches common issues
- pre-commit: Runs checks before each commit
Run all checks manually:
pre-commit run --all-files
Run tests with pytest:
pytest
Ruff is configured in both pyproject.toml
and .ruff.toml
. It includes rules for:
- Code style (PEP 8)
- Type annotations
- Security issues
- Best practices
Black is configured in pyproject.toml
and .black
with a line length of 88 characters.
isort is configured to be compatible with Black in pyproject.toml
and .isort.cfg
.
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add some amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request