python-style

在审查或编写代码时应用 Python 最佳实践,包括 PEP 8、类型注释、文档字符串和要避免的常见反模式。

📖 中文导读:在审查或编写代码时应用 Python 最佳实践,包括 PEP 8、类型注释、文档字符串和要避免的常见反模式。 以下正文为该技能的原始 SKILL.md 内容(英文),上方安装命令可直接使用。

name: python-style description: Apply Python best practices when reviewing or writing code, including PEP 8, type annotations, docstrings, and common anti-patterns to avoid.

Python Style Skill

Apply Python best practices when reviewing or writing code.

Style Guidelines

  • Follow PEP 8 for formatting
  • Use type annotations for all public functions (PEP 484)
  • Write docstrings for public APIs (PEP 257)
  • Prefer f-strings over .format() or % formatting

Common Issues to Flag

  • Missing type annotations on public functions
  • Mutable default arguments (def foo(items=[]))
  • Bare except clauses (except: instead of except Exception:)
  • Using assert for validation (stripped in optimized mode)

References