mirror of
https://github.com/cole-maxwell1/dotfiles.git
synced 2026-10-27 16:32:49 -05:00
- add conventions for Bash, C#, Go, Python, and TypeScript - add frontend guidance for HTMX, PrimeVue, and Vue - document formatting, typing, testing, async, and framework-specific practices - reference official documentation for framework API details
24 lines
971 B
Markdown
24 lines
971 B
Markdown
---
|
|
name: python
|
|
description: Python conventions (PEP 8, ruff, type hints). Use when editing .py files.
|
|
---
|
|
|
|
# Python Conventions
|
|
|
|
## Style
|
|
- Follow PEP 8; run `ruff check` and `ruff format` for linting and formatting.
|
|
- Let ruff manage line length and import ordering; do not hand-format against it.
|
|
|
|
## Typing
|
|
- Add type hints on all function signatures; prefer modern syntax (`list[int]`, `X | None`) on supported Python versions.
|
|
- Use `dataclasses` (or Pydantic where validation is required) for structured data.
|
|
- Prefer an explicit exception hierarchy over bare `except:`.
|
|
|
|
## Idioms
|
|
- Prefer `pathlib.Path` over `os.path`.
|
|
- Use f-strings for interpolation; use the `logging` module with structured handlers instead of `print` in libraries.
|
|
- Prefer comprehensions and generator expressions over manual loops where readability is preserved.
|
|
|
|
## Testing
|
|
- Use `unittest` (or `pytest` if the project adopts it); mirror the source layout under a `tests/` directory.
|