docs: 同步 Python 规范至 Google Python Style Guide 最新版#42
Merged
whg517 merged 2 commits intopyloong:mainfrom Apr 28, 2026
Merged
Conversation
基于 Google Python Style Guide 最新版本同步翻译文档,修复以下问题: language_rules.md: - 移除或修正与原文不一致的内容 - 补充遗漏的关键说明(如 self/cls 限定、generator_stop 示例) - 修复笔误和链接 - 更新代码示例以匹配原文 style_rules.md: - 同步 @OverRide 三种使用场景 - 更新循环累加示例格式 - 补充"避免缩写"命名规则 - 移除捏造的代码示例 - 类型标注现代化(Optional[X] → X | None) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
基于 pyguide.md 原文逐节对比,修正翻译与原文的遗漏和不一致。 language_rules.md: - §1.2: 保留 features 代码标识符而非误译为"功能" - §1.11: 补充"三元运算符"定义,修正"不推荐"示例换行 - §1.18: 修正 queue 模块名大小写 - §1.20: 修正错别字,决策段落与上游同步 style_rules.md: - §3.7: PEP-394 链接改为直链 - §3.8.2: one-line 连字符及缩进修正 - §3.8.3: 补充 Yields 生成器说明 - §3.10: 更新字符串累积示例,补充隐式拼接示例 - §3.11: 修正 h5py 链接,补充"卸载文件系统" - §3.12: TODO 格式与上游同步 - §3.13: 补充 collections.abc 导入例外 - §3.16.1: 补充数学符号命名例外 - §3.16.2: 补充单元测试访问受保护常量说明 - §3.19.10: unicode → str 术语更新 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
language_rules.md和style_rules.md的中文翻译,同步至 Google Python Style Guide 最新版pyguide.md原文逐节对比,修正翻译与原文的遗漏和不一致language_rules.md
viking_cafe_order添加类型标注 (str | None,-> str)features代码标识符而非误译为"功能"minimum: int,if not port→if port is None,更新 assert 指导get_adder和foo添加类型标注queue模块名大小写List[int]→list[int]style_rules.md
one line→one-line,修正缩进Yields:生成器说明@override装饰器章节i - 1→i-1{p!r}→{p=}collections.abc导入例外main(argv)→main(argv: Sequence[str])Self类型示例_P.args/_P.kwargs,unicode→strcollections.abc.Sequence优先指导,添加tuple/cast/TYPE_CHECKING#3106→#3196Test plan
!!! success/!!! fail)pyguide.md原文逐节对比验证🤖 Generated with Claude Code