stand-pylisted
Install: claude install-skill lgtm-hq/ai-skills
# Python Code Standards
Standards for Python code (>= 3.11).
## Runtime
- All Python code should be run with `uv`
## PEP Compliance
- PEP 604: Use union types as `X | Y` (not `Union[X, Y]`)
- PEP 673: Use `Self` type for self-referential types
## Required Elements
- Type hints on ALL function parameters
- Return types on ALL functions
- Docstrings in Google Style Guide format for:
- Modules
- Classes
- Functions/methods
## Docstring Format (Google Style)
```python
def function_with_docstring(
param1: str,
param2: int,
) -> bool:
"""Short description of function.
Longer description if needed.
Args:
param1: Description of param1.
param2: Description of param2.
Returns:
Description of return value.
Raises:
ValueError: When something is wrong.
"""
```
## Design Patterns
- Use `dataclasses` for structured records with fixed fields and named attributes
- Use `collections.defaultdict` for dynamic key-value aggregation with automatic
defaults
- Choose based on the use case: typed record-like object (`dataclass`) vs map with
default values (`defaultdict`)
- Each dataclass should be in a separate file
- String Enums should use `StrEnum` with `auto()`
- Use `auto()` with all Enums where it makes sense
## Idioms
Prefer Python-native constructs over verbose cross-language patterns.
- `any()`/`all()` over flag-and-break loops:
```python
# Don't
found = False
for p in paths:
if p.exist