Skip to content

refactor(legal-status): one date parser, typed status, single dispatch in refresh - #24

Open
corlin wants to merge 1 commit into
mainfrom
refactor/legal-status-simplify
Open

corlin wants to merge 1 commit into
mainfrom
refactor/legal-status-simplify

Conversation

@corlin

@corlin corlin commented Oct 8, 2026

Copy link
Copy Markdown
Owner

改了什么

  • 合并重复的日期解析:ep.py 的 _iso 与 us.py 的 _parse_date 逻辑完全相同;保留 us.parse_date,ep.py 改为引用它。
  • 状态值加类型:assess_us / assess_ep 内的 result() 参数由 str 改为已有的 Status 字面量类型,删除 2 处 # type: ignore[arg-type],拼错的状态值可被类型检查发现。
  • 刷新流程单次分派:LegalStatusRefresher.refresh 原先对 country == "US" 判断两次;现在每个分支取数后立即判定,EP 申请日在非空检查后才使用,删除第 3 处 type: ignore 和一个不再使用的 import。

判定行为不变(+29 / −32)。

验证

  • .venv/bin/pytest apps/api/tests/unit/:423 passed
  • ./scripts/test-postgres.sh:118 passed,1 failed —— test_search_api.py::test_search_planning_and_candidate_triage_lifecycle,两次运行分别因 OpenAlex 实时请求 ReadTimeout 和 HTTP 429 返回 502;该测试依赖外网,与本改动无关(另行处理)。
  • 未运行 mypy / ruff:.venv 中未安装。

🤖 Generated with Claude Code

…h in refresh

- ep.py reused an identical copy of us.py's ISO date parser (_iso);
  it now imports us.parse_date.
- result() in assess_us/assess_ep takes Status instead of str, dropping
  two type: ignore[arg-type].
- LegalStatusRefresher.refresh assessed in a second country == "US"
  branch; each branch now assesses right after fetching, so the EP
  filing date is narrowed and the third type: ignore goes away.

No behaviour change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

1 participant