Python Best Practices
以下摘录自该仓库的 README(片段) · 在 GitHub 读完整 README →
Modern Python 3.12+ patterns your AI agent should use. Type hints with X | Y syntax, Pydantic v2,
uv package manager, match statements, pathlib, pyproject.toml, TaskGroup, and PEP 695
generics.
> AI coding assistants generate from typing import List, Union, Optional, use Pydantic v1
> decorators, create setup.py, and reach for os.path instead of pathlib. This plugin keeps
> your agent on Python 3.12+ patterns.
Install
Cursor / Claude Code / Windsurf
Or copy skills/ into your .cursor/skills/ or .claude/skills/ directory.
What's Included
| Type | Name | Description |
| ------- | ----------------------- | ---------------------------------------------------------------------------------- |
| Skill | python-best-practices | 15 rules for type hints, Pydantic v2, uv, pathlib, match/case, TaskGroup, and more |
| Rule | best-practices | Always-on behavioral rule that enforces Python 3.12+ patterns |
| Command | /audit | Scan your codebase for outdated Python patterns |
What Agents Get Wrong
| What the agent writes | What Python 3.12+ uses |
| ------------------------------------------ | -------------------------------------------------- |
| from typing import List, Union, Optional | list[str], X \| Y, X \| None |
| @validator, @root_validator | field_validator, model_validator (Pydantic v2) |
| class Config: in Pydantic models | model_config = ConfigDict(...) |
| os.path.join(), string paths | pathlib.Path for all file operations |
| setup.py, requirements.txt | pyproject.toml with uv |
| TypeVar("T") + Generic[T] | def fT -> T (PEP 695) |
| asyncio.gather() | TaskGroup for structured concurrency |
Related Plugins
- fastapi-best-practices - FastAPI async
patterns, Depends(), project structure
- typescript-best-practices - TypeScript
5.x strict patterns
---
If this helped your workflow, a star helps others find it.