Files
everything-claude-code/docs/zh-CN/rules/python/coding-style.md
zdoc.app 95f63c3cb0 docs(zh-CN): sync Chinese docs with latest upstream changes (#202)
* docs(zh-CN): sync Chinese docs with latest upstream changes

* docs: improve Chinese translation consistency in go-test.md

* docs(zh-CN): update image paths to use shared assets directory

- Update image references from ./assets/ to ../../assets/
- Remove zh-CN/assets directory to use shared assets

---------

Co-authored-by: neo <neo.dowithless@gmail.com>
2026-02-13 01:04:58 -08:00

38 lines
700 B
Markdown

# Python 编码风格
> 本文件在 [common/coding-style.md](../common/coding-style.md) 的基础上扩展了 Python 特定的内容。
## 标准
* 遵循 **PEP 8** 规范
* 在所有函数签名上使用 **类型注解**
## 不变性
优先使用不可变数据结构:
```python
from dataclasses import dataclass
@dataclass(frozen=True)
class User:
name: str
email: str
from typing import NamedTuple
class Point(NamedTuple):
x: float
y: float
```
## 格式化
* 使用 **black** 进行代码格式化
* 使用 **isort** 进行导入排序
* 使用 **ruff** 进行代码检查
## 参考
查看技能:`python-patterns` 以获取全面的 Python 惯用法和模式。