Skip to content

fix: 清零 sourcery gate 16 项 issue - #42

Merged
im47cn merged 2 commits into
mainfrom
fix/sourcery-issues
Oct 18, 2026
Merged

im47cn merged 2 commits into
mainfrom
fix/sourcery-issues

Conversation

@im47cn-bot

@im47cn-bot im47cn-bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

#39 合并后 sourcery gate 红的根因是 16 项未清零 issue(非 SOURCERY_TOKEN:CI 日志显示 token 注入正常、review 完整运行)。修复:except 元组删 FileNotFoundError 子类冗余×2、_discover 抛错补 from exc、explicit 分支内联、_strip_bom 折三元、_bind_root 删 if-pass 死块、path=='' 改 not、transport env 海象、_available_transports 删两分支同值冗余 return、chunks 循环海象+else、tuple() 字面量、测试共享 helper 提取 tests/helpers.py(dont-import-test-modules)。全量测试 118 绿(本地排除 bdd:缺 pytest_bdd 环境项)。

Sourcery 总结

简化配置和传输相关代码,并整理测试共享工具,以解决 Sourcery gate 中报告的问题。

Bug 修复:

  • 清理配置发现、解析、校验和传输选择中的冗余逻辑,并改进配置资源错误的异常链信息。

增强功能:

  • 统一测试共享辅助函数,避免测试模块之间相互导入。
Original summary in English

Summary by Sourcery

简化配置与传输相关代码并整理测试共享工具,以消除 Sourcery gate 中报告的问题。

Bug Fixes:

  • 清理配置发现、解析、校验及传输选择中的冗余逻辑,并改进配置资源错误的异常链信息。

Enhancements:

  • 统一测试共享辅助函数,避免测试模块之间相互导入。
Original summary in English

@im47cn-bot
im47cn-bot requested a review from im47cn as a code owner October 18, 2026 09:57
@changeset-bot

changeset-bot Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 5df1cf7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@coderabbitai

coderabbitai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: f083983f-d645-4ec4-a521-a0d436c93019
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@sourcery-ai

sourcery-ai Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

审查者指南

本 PR 针对 Sourcery gate 的 16 项 issue 进行定向清理:通过删除冗余异常类型、分支和无效代码,简化表达式与循环,并补充异常链;同时将测试共享 helper 提取到独立模块以满足 dont-import-test-modules 规则,保持既有行为和测试覆盖不变。

文件级变更

Change Details Files
简化配置发现与异常处理逻辑,消除冗余并保留原有错误语义。
  • 移除 FileNotFoundError 在 OSError 中的冗余捕获
  • 为打包配置发现错误补充异常链
  • 内联显式配置路径分支
src/wop_sdk/config/_loader.py
采用更简洁的 Python 表达方式替换无效或冗余实现。
  • 使用空元组字面量初始化备份地址
  • 删除未知字段处理中的无效 if-pass 代码
  • 将空路径判断简化为 not path
src/wop_sdk/config/_models.py
src/wop_sdk/config/_parser.py
src/wop_sdk/config/_validator.py
精简传输实现和发现逻辑,减少重复分支。
  • 使用海象运算符读取显式 transport 环境变量
  • 删除仅 urllib 时与默认返回相同的特殊分支
  • 使用海象运算符和 else 简化响应分块循环
src/wop_sdk/transport_discovery.py
src/wop_sdk/transports/urllib_transport.py
提取测试共享数据构造与配置写入逻辑,避免测试模块之间相互导入。
  • 新增独立 helpers 模块集中维护 RSA 套件常量及配置辅助函数
  • 更新配置相关测试以复用共享 helper
tests/helpers.py
tests/test_config.py
tests/test_config_loading.py

可能关联的问题

  • #未提供: PR 清理 Sourcery 检查项并调整测试 helper,旨在修复该提交触发的 CI 失败。

提示与命令

与 Sourcery 交互

  • 触发新一轮审查: 在 pull request 上评论 @sourcery-ai review。
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论创建 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以在审查评论中回复 @sourcery-ai issue,以此创建 issue。
  • 生成 pull request 标题: 在 pull request 标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在 pull request 上评论 @sourcery-ai title,以随时(重新)生成标题。
  • 生成 pull request 摘要: 在 pull request 正文中你希望生成摘要的位置写入 @sourcery-ai summary,即可随时生成 PR 摘要。你也可以在 pull request 上评论 @sourcery-ai summary,以随时(重新)生成摘要。
  • 生成审查者指南: 在 pull request 上评论 @sourcery-ai guide,即可随时(重新)生成审查者指南。
  • 解决所有 Sourcery 评论: 在 pull request 上评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已处理完所有评论且不想再看到它们,这个功能会很有用。
  • 关闭所有 Sourcery 审查: 在 pull request 上评论 @sourcery-ai dismiss,即可关闭所有现有的 Sourcery 审查。如果你想从头开始新一轮审查,这尤其有用——别忘了评论 @sourcery-ai review 来触发新一轮审查!

自定义使用体验

访问你的控制面板,可以:

  • 启用或禁用审查功能,例如 Sourcery 生成的 pull request 摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查说明。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

本 PR 针对 Sourcery gate 的 16 项 issue 进行定向清理:通过删除冗余异常类型、分支和无效代码,简化表达式与循环,并补充异常链;同时将测试共享 helper 提取到独立模块以满足 dont-import-test-modules 规则,保持既有行为和测试覆盖不变。

File-Level Changes

Change Details Files
简化配置发现与异常处理逻辑,消除冗余并保留原有错误语义。
  • 移除 FileNotFoundError 在 OSError 中的冗余捕获
  • 为打包配置发现错误补充异常链
  • 内联显式配置路径分支
src/wop_sdk/config/_loader.py
采用更简洁的 Python 表达方式替换无效或冗余实现。
  • 使用空元组字面量初始化备份地址
  • 删除未知字段处理中的无效 if-pass 代码
  • 将空路径判断简化为 not path
src/wop_sdk/config/_models.py
src/wop_sdk/config/_parser.py
src/wop_sdk/config/_validator.py
精简传输实现和发现逻辑,减少重复分支。
  • 使用海象运算符读取显式 transport 环境变量
  • 删除仅 urllib 时与默认返回相同的特殊分支
  • 使用海象运算符和 else 简化响应分块循环
src/wop_sdk/transport_discovery.py
src/wop_sdk/transports/urllib_transport.py
提取测试共享数据构造与配置写入逻辑,避免测试模块之间相互导入。
  • 新增独立 helpers 模块集中维护 RSA 套件常量及配置辅助函数
  • 更新配置相关测试以复用共享 helper
tests/helpers.py
tests/test_config.py
tests/test_config_loading.py

Possibly linked issues

  • #未提供: PR 清理 Sourcery 检查项并调整测试 helper,旨在修复该提交触发的 CI 失败。

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

嘿——我已经审查了你的更改,整体看起来很棒!

Sourcery 评估

已批准。


Sourcery 对开源项目免费——如果你喜欢我们的评审,欢迎分享 ✨
Original comment in English

Hey - I've reviewed your changes and they look great!

Sourcery assessment

Approved.


Sourcery is free for open source - if you like our reviews please consider sharing them ✨

@im47cn
im47cn enabled auto-merge October 18, 2026 10:07
@im47cn
im47cn merged commit 4499112 into main Oct 18, 2026
24 checks passed
@im47cn
im47cn deleted the fix/sourcery-issues branch October 18, 2026 10:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants