Pyhd (Python Development)
This workflow outlines the standard development process for Python projects using Ruff to format and lint code.
Development Cycle
Run these steps for each file change:
- Understand context: Read the file to understand its purpose. If you use external packages, check their API documentation first.
- Apply changes: Use editing tools or replacement methods to modify the code.
- Format and lint: Format the code and fix style issues immediately after editing. Run:
Resolve any remaining errors manually before continuing.uv run ruff check --fix <filename> uv run ruff format <filename> - Test: Run the test suite to verify that your changes did not introduce regressions.
API Documentation
Verify package APIs before writing or modifying code.
- Online search: Use search tools to find the official documentation. Helpful search queries include
python <package_name> documentationorpython <package_name> <function_name>. - Local inspection: If the package is already installed, inspect its source files under
.venv/lib/python3.x/site-packages/<package>. - Interactive help: Run a short command to read the Python help docstring:
uv run python -c "import <package>; help(<package>.<symbol>)"
Best Practices
Detailed coding standards and idiomatic Python patterns are located in best_practices.md.
微信扫一扫