| name | python-guru |
| description | Enforces modern Python 3.12+ best practices when writing, reviewing, or refactoring Python code. Use when the user asks for Python help, code review, idiomatic Python, Pythonic patterns, Python project setup, debugging, or performance advice. Covers modern tooling (uv, ruff, pyright), type system (PEP 695 generics, Protocol, TypeIs), async (TaskGroup, timeout), testing (pytest + Hypothesis), security, and anti-pattern elimination. Do NOT use for general software architecture unrelated to Python. |
| version | 1.0.0 |
Python Guru
Enforce modern, idiomatic Python 3.12+ across every task. Never suggest
deprecated patterns, legacy tooling, or outdated idioms. When in doubt,
check the reference files before answering.
When to Use
- Writing new Python code of any kind
- Reviewing or refactoring existing Python code
- Setting up a new Python project (structure, tooling, CI)
- Debugging Python errors or unexpected behaviour
- Advising on async, typing, testing, or performance
- User asks: "is this Pythonic?", "how do I do X in Python?", "review my code"
When NOT to Use
- Pure architecture discussions with no Python specifics
- Non-Python languages (even in mixed-language repos)
- System administration tasks where Python is incidental
Enforcement Checklist
Run through this for every block of Python code you write or review:
Tooling
Types
Async
Testing
Security
Common Anti-Patterns (instant fail)
Quick-Reference: Old ā New
| Old (pre-2024) | New (2026) |
|---|
pip + virtualenv + pyenv | uv |
black + isort + flake8 | ruff format + ruff check |
TypeVar("T") | [T] inline type parameter |
Optional[X] | X | None |
Union[A, B] | A | B |
Dict[str, int], List[int] | dict[str, int], list[int] |
TypeAlias annotation | type Alias = ... statement |
asyncio.gather() | asyncio.TaskGroup |
asyncio.wait_for() | asyncio.timeout() |
datetime.utcnow() | datetime.now(UTC) |
setup.py / setup.cfg | pyproject.toml only |
ABC for interfaces | Protocol |
@dataclass | @dataclass(slots=True) |
Project Bootstrap
For a new Python project, create this structure immediately:
my-project/
āāā src/
ā āāā my_package/
ā āāā __init__.py # define __all__
ā āāā ...
āāā tests/
ā āāā conftest.py
ā āāā test_*.py
āāā pyproject.toml
āāā uv.lock # commit for apps; gitignore for libraries
āāā mise.toml # optional but recommended
Bootstrap commands:
uv init my-project --lib
cd my-project
uv add --dev pytest ruff pyright hypothesis
Minimal pyproject.toml:
[project]
requires-python = ">=3.12"
[tool.ruff]
target-version = "py312"
[tool.ruff.lint]
select = ["E","W","F","I","B","C4","UP","SIM","TCH","RUF","PT","S","ANN"]
ignore = ["ANN101","ANN102","ANN401"]
[tool.pyright]
pythonVersion = "3.12"
typeCheckingMode = "standard"
[tool.pytest.ini_options]
testpaths = ["tests"]
addopts = "--strict-markers -q"
[tool.coverage.run]
source = ["src"]
branch = true
[tool.coverage.report]
fail_under = 90
References
Load these files when you need depth beyond this overview:
references/tooling.md ā uv, ruff, pyright, mise configuration + CI setup
references/type-system.md ā full type annotation guide, PEP 695, Protocol, TypedDict
references/async.md ā async patterns, TaskGroup, pitfalls, anyio
references/testing.md ā pytest fixtures, Hypothesis strategies, coverage
references/security.md ā injection prevention, secrets, subprocess safety, t-strings
references/anti-patterns.md ā comprehensive anti-pattern catalogue with fixes