---
paths:
  - "**/*.py"
  - "**/*.pyi"
---
# Python Automation in Pi

> This file extends `common/hooks.md` with Python-specific automation guidance.

Pi extension events replace harness-specific hook configuration. Do not assume an extension is installed or edit global Pi configuration without user approval.

## After Python Edits

Use the repository's configured commands, in this order when applicable:

1. Format or check the edited files with the configured formatter.
2. Run the configured linter on the narrowest relevant scope.
3. Run the configured type checker.
4. Run focused tests, then the broader suite when warranted.

For Python commands, respect the package and environment manager established by the project. Do not silently install Black, Ruff, mypy, pyright, or any other tool.

## Optional Extension Automation

A trusted Pi extension may automate these checks with `tool_result` or run settled-state verification with `agent_settled`. Extension behavior must preserve user changes, report failures, and avoid formatting unrelated files.

## Logging Audit

Flag stray `print()` calls in production code when the project uses structured logging. Keep intentional CLI output and tests when appropriate.
