Loading...
Loading...
Compare original and translation side by side
undefinedundefinedundefinedundefinedundefinedundefinedundefinedundefinedclass MyLibError(Exception):
"""Base exception with helpful messages."""
def __init__(self, message: str, *, hint: str = None):
super().__init__(message)
self.hint = hintclass MyLibError(Exception):
"""Base exception with helpful messages."""
def __init__(self, message: str, *, hint: str = None):
super().__init__(message)
self.hint = hintundefinedundefinedimport warnings
def old_function():
warnings.warn(
"old_function() deprecated, use new_function()",
DeprecationWarning,
stacklevel=2,
)
return new_function()import warnings
def old_function():
warnings.warn(
"old_function() deprecated, use new_function()",
DeprecationWarning,
stacklevel=2,
)
return new_function()undefinedundefined
For detailed patterns, see:
- **[PATTERNS.md](PATTERNS.md)** - Builder, factory, and advanced patterns
- **[EVOLUTION.md](EVOLUTION.md)** - API versioning and migration guides
如需了解详细模式,请查看:
- **[PATTERNS.md](PATTERNS.md)** - 构建器、工厂及高级模式
- **[EVOLUTION.md](EVOLUTION.md)** - API版本管理与迁移指南Naming:
- [ ] Clear, self-documenting names
- [ ] Consistent patterns throughout
- [ ] Boolean params read naturally
Parameters:
- [ ] Minimal required parameters
- [ ] Sensible defaults
- [ ] Keyword-only after positional clarity
Errors:
- [ ] Custom exceptions with context
- [ ] Helpful error messages
- [ ] Documented in docstrings命名:
- [ ] 清晰、自文档化的命名
- [ ] 全程遵循一致的命名模式
- [ ] 布尔型参数表述自然
参数:
- [ ] 仅保留必要的最少参数
- [ ] 合理的默认值
- [ ] 位置参数明确后使用关键字-only参数
错误:
- [ ] 带上下文的自定义异常
- [ ] 有帮助性的错误信息
- [ ] 在文档字符串中记录异常信息