forge-lang-python
Python development standards including pytest, ruff, black, and mypy. Use when working with Python files, tests, or dependencies.
When & Why to Use This Skill
This Claude skill establishes a robust Python development environment by integrating industry-standard tools for testing, linting, and formatting. It provides ready-to-use commands for pytest, ruff, and mypy, alongside standardized project structures and TDD workflows to enhance code quality and developer productivity.
Use Cases
- Automated Testing: Streamline unit testing and generate detailed coverage reports using pytest to maintain high software reliability.
- Code Quality Enforcement: Use ruff and mypy to automatically detect linting issues, enforce formatting standards, and perform static type checking.
- Project Initialization: Quickly scaffold new Python projects with standardized directory structures and optimized pyproject.toml configurations.
- Test-Driven Development (TDD): Facilitate the Red-Green-Refactor cycle with integrated commands that combine testing, linting, and formatting in a single workflow.
| name | forge-lang-python |
|---|---|
| description | Python development standards including pytest, ruff, black, and mypy. Use when working with Python files, tests, or dependencies. |
Python Development
Testing
# Run all tests
pytest
# Run with coverage
pytest --cov=src --cov-report=term-missing
# Run specific test
pytest tests/test_module.py::test_function
# Run with verbose output
pytest -v
Linting
# Check with ruff
ruff check .
# Fix auto-fixable issues
ruff check --fix .
# Type checking
mypy src/
Formatting
# Format with ruff (or black)
ruff format .
# Check without changing
ruff format --check .
# Sort imports
ruff check --select I --fix .
Project Structure
project/
├── src/
│ └── package/
│ ├── __init__.py
│ └── module.py
├── tests/
│ ├── __init__.py
│ ├── conftest.py
│ └── test_module.py
├── pyproject.toml
└── README.md
pyproject.toml Template
[project]
name = "package-name"
version = "0.1.0"
requires-python = ">=3.10"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "-ra -q"
[tool.ruff]
line-length = 88
select = ["E", "F", "I", "N", "W"]
[tool.ruff.format]
quote-style = "double"
[tool.mypy]
python_version = "3.10"
strict = true
TDD Cycle Commands
# RED: Write test, run to see it fail
pytest tests/test_new_feature.py -v
# GREEN: Implement, run to see it pass
pytest tests/test_new_feature.py -v
# REFACTOR: Clean up, ensure tests still pass
pytest && ruff check . && ruff format --check .