A modern Python project template with best practices and essential tooling.
- Modern project structure using
srclayout pyproject.tomlfor project configuration- Testing setup with pytest
- Code formatting with Black
- Linting with flake8
- Type checking with mypy
- Import sorting with isort
- Comprehensive .gitignore for Python projects
.
├── src/
│ └── project_name/ # Main package directory
│ ├── __init__.py
│ └── main.py
├── tests/ # Test files
│ ├── __init__.py
│ └── test_main.py
├── docs/ # Documentation
├── .gitignore
├── pyproject.toml # Project configuration
├── requirements.txt # Production dependencies
├── requirements-dev.txt # Development dependencies
└── README.md
# Clone the repository
git clone <your-repo-url>
cd python-project-template
# Create a virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install in editable mode with dev dependencies
pip install -e ".[dev]"pip install -r requirements.txtfrom project_name import main
# Your code here# Run all tests
pytest
# Run with coverage report
pytest --cov=src --cov-report=html# Format code with Black
black src tests
# Sort imports
isort src tests# Run flake8
flake8 src tests
# Run type checking
mypy src- Fork the repository
- Create a 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
MIT License - see LICENSE file for details