dignified-python
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseDignified Python Coding Standards Skill
严谨规范的Python编码标准技能
Production-quality Python coding standards for writing clean, maintainable, modern Python code
(versions 3.10-3.13).
适用于编写整洁、可维护的现代Python代码的生产级编码标准(支持版本3.10-3.13)。
When to Use This Skill
何时使用本技能
Auto-invoke when users ask about:
- "make this pythonic" / "is this good python"
- "type hints" / "type annotations" / "typing"
- "LBYL vs EAFP" / "exception handling"
- "pathlib vs os.path" / "path operations"
- "CLI patterns" / "click usage"
- "code review" / "improve this code"
- Any Python code quality or standards question
Note: This skill is general Python standards, not Dagster-specific. Use
for Dagster patterns.
/dagster-best-practices当用户询问以下内容时自动调用:
- "让这段代码更符合Python风格" / "这段Python代码写得好吗"
- "类型提示" / "类型注解" / "类型标注"
- "LBYL vs EAFP" / "异常处理"
- "pathlib vs os.path" / "路径操作"
- "CLI模式" / "click使用方法"
- "代码审查" / "优化这段代码"
- 任何关于Python代码质量或编码标准的问题
注意:本技能是通用Python编码标准,不针对Dagster。若需Dagster相关模式,请使用。
/dagster-best-practicesWhen to Use This Skill vs. Others
本技能与其他技能的适用场景对比
| User Need | Use This Skill | Alternative Skill |
|---|---|---|
| "make this pythonic" | ✅ Yes - Python standards | |
| "is this good python" | ✅ Yes - code quality | |
| "type hints" | ✅ Yes - typing guidance | |
| "LBYL vs EAFP" | ✅ Yes - exception patterns | |
| "pathlib vs os.path" | ✅ Yes - path handling | |
| "best practices for dagster" | ❌ No | |
| "implement X pipeline" | ❌ No | |
| "which integration to use" | ❌ No | |
| "CLI argument parsing" | ✅ Yes - CLI patterns |
| 用户需求 | 使用本技能 | 替代技能 |
|---|---|---|
| "让这段代码更符合Python风格" | ✅ 是 - Python编码标准 | |
| "这段Python代码写得好吗" | ✅ 是 - 代码质量检查 | |
| "类型提示" | ✅ 是 - 类型标注指导 | |
| "LBYL vs EAFP" | ✅ 是 - 异常处理模式 | |
| "pathlib vs os.path" | ✅ 是 - 路径处理规范 | |
| "Dagster最佳实践" | ❌ 否 | |
| "实现X流水线" | ❌ 否 | |
| "使用哪个集成工具" | ❌ 否 | |
| "CLI参数解析" | ✅ 是 - CLI模式规范 |
Core Knowledge (ALWAYS Loaded)
核心知识(始终加载)
@dignified-python-core.md
@dignified-python-core.md
Version Detection
版本检测
Identify the project's minimum Python version by checking (in order):
- - Look for
pyproject.tomlfield (e.g.,requires-python)requires-python = ">=3.12" - or
setup.py- Look forsetup.cfgpython_requires - file - Contains version like
.python-versionor3.123.12.0 - Default to Python 3.12 if no version specifier found
Once identified, load the appropriate version-specific file:
- Python 3.10: Load
versions/python-3.10.md - Python 3.11: Load
versions/python-3.11.md - Python 3.12: Load
versions/python-3.12.md - Python 3.13: Load
versions/python-3.13.md
识别项目的最低Python版本,按以下顺序检查:
- - 查找
pyproject.toml字段(例如:requires-python)requires-python = ">=3.12" - 或
setup.py- 查找setup.cfgpython_requires - 文件 - 包含类似
.python-version或3.12的版本号3.12.0 - 若未找到版本指定,默认使用Python 3.12
识别版本后,加载对应的版本特定文件:
- Python 3.10:加载
versions/python-3.10.md - Python 3.11:加载
versions/python-3.11.md - Python 3.12:加载
versions/python-3.12.md - Python 3.13:加载
versions/python-3.13.md
Conditional Loading (Load Based on Task Patterns)
条件加载(根据任务模式加载)
Core files above cover 80%+ of Python code patterns. Only load these additional files when you
detect specific patterns:
Pattern detection examples:
- If task mentions "click" or "CLI" -> Load
references/cli-patterns.md - If task mentions "subprocess" -> Load subprocess patterns from core-standards
上述核心文件覆盖了80%以上的Python代码模式。仅当检测到特定模式时,才加载以下附加文件:
模式检测示例:
- 若任务提及"click"或"CLI" -> 加载
references/cli-patterns.md - 若任务提及"subprocess" -> 从核心标准中加载subprocess相关模式
Reference Documentation Structure
参考文档结构
The directory contains detailed guidance organized by topic:
references/references/Core References
核心参考文档
- - Essential standards (always loaded)
core-standards.md - - Command-line interface patterns (click, argparse)
cli-patterns.md
- - 基础编码标准(始终加载)
core-standards.md - - 命令行界面模式(click、argparse)
cli-patterns.md
Version-Specific References (references/versions/
)
references/versions/版本特定参考文档(references/versions/
)
references/versions/- - Features available in Python 3.10+
python-3.10.md - - Features available in Python 3.11+
python-3.11.md - - Features available in Python 3.12+
python-3.12.md - - Features available in Python 3.13+
python-3.13.md
- - Python 3.10及以上版本可用特性
python-3.10.md - - Python 3.11及以上版本可用特性
python-3.11.md - - Python 3.12及以上版本可用特性
python-3.12.md - - Python 3.13及以上版本可用特性
python-3.13.md
Advanced Topics (references/advanced/
)
references/advanced/进阶主题(references/advanced/
)
references/advanced/- - LBYL patterns, error boundaries
exception-handling.md - - ABC and Protocol patterns
interfaces.md - - Advanced typing patterns
typing-advanced.md - - API design principles
api-design.md
- - LBYL模式、错误边界
exception-handling.md - - ABC和Protocol模式
interfaces.md - - 进阶类型标注模式
typing-advanced.md - - API设计原则
api-design.md
When to Read Each Reference Document
各参考文档的适用场景
references/advanced/exception-handling.md
references/advanced/exception-handling.mdreferences/advanced/exception-handling.md
references/advanced/exception-handling.mdRead when:
- Writing try/except blocks
- Wrapping third-party APIs that may raise
- Seeing or writing or
from efrom None - Unsure if LBYL alternative exists
何时阅读:
- 编写try/except代码块时
- 封装可能抛出异常的第三方API时
- 看到或编写或
from e时from None - 不确定是否有LBYL替代方案时
references/advanced/interfaces.md
references/advanced/interfaces.mdreferences/advanced/interfaces.md
references/advanced/interfaces.mdRead when:
- Creating ABC or Protocol classes
- Writing @abstractmethod decorators
- Designing gateway layer interfaces
- Choosing between ABC and Protocol
何时阅读:
- 创建ABC或Protocol类时
- 编写@abstractmethod装饰器时
- 设计网关层接口时
- 在ABC和Protocol之间做选择时
references/advanced/typing-advanced.md
references/advanced/typing-advanced.mdreferences/advanced/typing-advanced.md
references/advanced/typing-advanced.mdRead when:
- Using typing.cast()
- Creating Literal type aliases
- Narrowing types in conditional blocks
何时阅读:
- 使用typing.cast()时
- 创建Literal类型别名时
- 在条件块中缩小类型范围时
references/module-design.md
references/module-design.mdreferences/module-design.md
references/module-design.mdRead when:
- Creating new Python modules
- Adding module-level code (beyond simple constants)
- Using @cache decorator at module level
- Seeing Path() or computation at module level
- Considering inline imports
何时阅读:
- 创建新的Python模块时
- 添加模块级代码(除简单常量外)时
- 在模块级使用@cache装饰器时
- 在模块级看到Path()或计算逻辑时
- 考虑使用内联导入时
references/api-design.md
references/api-design.mdreferences/api-design.md
references/api-design.mdRead when:
- Adding default parameter values to functions
- Defining functions with 5 or more parameters
- Using ThreadPoolExecutor.submit()
- Reviewing function signatures
何时阅读:
- 为函数添加默认参数值时
- 定义包含5个或更多参数的函数时
- 使用ThreadPoolExecutor.submit()时
- 审查函数签名时
references/checklists.md
references/checklists.mdreferences/checklists.md
references/checklists.mdRead when:
- Final review before committing Python code
- Unsure if you've followed all rules
- Need a quick lookup of requirements
何时阅读:
- 提交Python代码前的最终审查时
- 不确定是否遵循了所有规则时
- 需要快速查阅要求时
How to Use This Skill
如何使用本技能
- Core knowledge is loaded automatically (LBYL, pathlib, basic imports, anti-patterns)
- Version detection happens once - identify the minimum Python version and load the appropriate version file
- Reference documents are loaded on-demand based on the triggers above
- Additional patterns may require extra loading (CLI patterns, subprocess)
- Each file is self-contained with complete guidance for its domain
- 核心知识自动加载(LBYL、pathlib、基础导入、反模式)
- 版本检测仅执行一次 - 识别最低Python版本并加载对应的版本文件
- 参考文档根据上述触发条件按需加载
- 其他模式可能需要额外加载(如CLI模式、subprocess)
- 每个文件都是独立的,包含其领域的完整指导