741 B
741 B
paths:
- "**/*.py"
- "**/*.pyi"
Python 程式碼風格
本檔案延伸 common/coding-style.md,提供 Python 特定內容。
標準規範
- 遵循 PEP 8 規範
- 在所有函式簽名上使用 type annotations
不可變性
優先使用不可變資料結構:
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 用於 import 排序
- ruff 用於 linting
參考資源
參見 skill: python-patterns,提供完整的 Python 慣用法與模式。