Skip to content

fix: LabelMeReader raises on unreadable input instead of returning None - #156

Open
zw1915 wants to merge 1 commit into
petercorke:mainfrom
zw1915:fix/agent-150
Open

zw1915 wants to merge 1 commit into
petercorke:mainfrom
zw1915:fix/agent-150

Conversation

@zw1915

@zw1915 zw1915 commented Oct 17, 2026 •

Copy link
Copy Markdown

修复内容 / What this fixes

Closes #150

LabelMeReader.__init__ 原先把文件/JSON/URL 读取包在一个宽泛的 try/except 里,
吞掉 OSError、json.JSONDecodeError、TypeError、ValueError 后 return None,
留下一个半初始化的 reader,调用方要到很晚才会以一个莫名其妙的错误失败。
现在原始异常直接抛出,带原始信息和 traceback —— 正是这个 issue 要求的行为。

实现思路 / Approach

去掉这层 try/except,让加载阶段的原始异常自然传播。不引入新的异常类型、
不改公共 API。改动范围仅限 #150 中这一个 quick-win 项,其余项留给独立 PR。

验证 / Verification

$ pytest -q tests/test_image_sources.py
9 passed, 20 skipped, 5 subtests passed in 2.26s

(skipped 的用例需要 ROS / 视频文件等本地不具备的环境。)

备注 / Notes

  • 改动范围已控制在最小可行范围,未触碰无关代码。
  • 如与仓库既有约定不符,请在评论中指出,我会立即调整。

本 PR 由自动化流水线准备:提交前经过语法检查与自审,未触碰无关代码。

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

Closes petercorke#150

LabelMeReader.__init__ used to wrap file/JSON/URL loading in a broad
try/except that swallowed OSError, json.JSONDecodeError, TypeError and
ValueError and returned None, leaving a half-initialised reader whose
callers only failed later with a confusing error. The original exception
now propagates with its message and traceback.

Scoped to this single quick-win item from petercorke#150; the other items in that
umbrella issue are left for separate PRs.

Signed-off-by: agentops <agentops@users.noreply.github.com>
@zw1915 zw1915 changed the title fix: Sources.py: quick wins, split into a package, and API unification fix: LabelMeReader raises on unreadable input instead of returning None Oct 17, 2026

This branch has not been deployed

No deployments
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.

Sources.py: quick wins, split into a package, and API unification

2 participants