Files
cps-develop-docs/.github/instructions/python.instructions.md

15 lines
696 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
applyTo: "**/*.py"
description: "用于 Python 编码实现关键词Type Hints、Ruff、Mypy、异常处理、上下文管理器"
---
# Python 编码约束
- Python 代码必须使用完整 Type Hints避免 Any 滥用。
- 命名遵循 snake_case / PascalCase / SCREAMING_SNAKE_CASE。
- 禁止吞噬异常(如 `except Exception: pass`)。
- 资源访问必须优先使用上下文管理器(`with`)。
- 新增代码应保持 Ruff/Mypy 友好,避免引入风格与静态检查噪音。
- 测试框架默认 pytest测试结构遵循 Arrange/Act/Assert。
- 参考规范:`03 - Coding & Frameworks/01 - Language Coding Specification/Python 编码与开发规范.md`