Skip to content

refactor: remove dead shared rate-limit handlers - #3140

Merged
IsmaelMartinez merged 2 commits into
The-PR-Agent:mainfrom
Tiancheng-Xu:fix/3139-dead-rate-limit-handlers
Sep 7, 2026
Merged

refactor: remove dead shared rate-limit handlers#3140
IsmaelMartinez merged 2 commits into
The-PR-Agent:mainfrom
Tiancheng-Xu:fix/3139-dead-rate-limit-handlers

Conversation

@Tiancheng-Xu

Copy link
Copy Markdown
Contributor

Summary

  • Remove the unused module-level PyGithub RateLimitExceededException import from the shared diff-processing path.
  • Remove the three handlers that could never match after providers translate rate-limit failures to the project-level RateLimitExceeded exception.
  • Keep GitHub retry and exception translation unchanged in GithubProvider.
  • Add regression coverage for propagation through all three shared diff entry points and for the provider-agnostic import boundary.

Closes #3139

Why this does not change runtime behavior

GithubProvider._get_diff_files() already converts the PyGithub exception to the project-level RateLimitExceeded exception, and GithubProvider.get_diff_files() retries that project exception before it returns. The shared handlers only logged and re-raised RateLimitExceededException, so they were unreachable for GitHub and for every other provider. Removing them leaves the actual retry and conversion behavior in the provider where it already occurs; other exceptions still propagate normally from the shared path.

Verification

  • PYTHONPATH=. uv run pytest tests/unittest -q — 4232 passed, 1 skipped, 1 xfailed.
  • uv run ruff check pr_agent/algo/pr_processing.py tests/unittest/test_pr_processing_core.py — passed.
  • uv run pre-commit run --files pr_agent/algo/pr_processing.py tests/unittest/test_pr_processing_core.py — passed.
  • git diff --check — passed.

中文说明

本 PR 删除共享 diff 路径中永远匹配不到的 PyGithub 限流异常导入、三个 handler 和过时的 Raises 文档。GitHub provider 原有的重试与项目级 RateLimitExceeded 转换保持不变,因此不改变运行时行为;新增测试覆盖三个共享入口的项目级异常传播及 provider-agnostic 导入边界。

Copilot AI lite review requested due to automatic review settings September 7, 2026 13:13
@Tiancheng-Xu

Copy link
Copy Markdown
Contributor Author

/agentic_review

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

The new AST-based import-boundary test only checks top-level nodes (tree.body) and can miss nested imports, weakening the intended regression coverage.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR removes unreachable PyGithub-specific rate-limit handling from the shared diff-processing layer (pr_processing.py), relying on providers to surface the project-level RateLimitExceeded exception, and adds regression tests to ensure that exception propagates through the shared diff entry points.

Changes:

  • Removed the module-scope RateLimitExceededException import and the three dead except RateLimitExceededException handlers in pr_agent/algo/pr_processing.py.
  • Added unit tests asserting RateLimitExceeded propagation through get_pr_diff, get_pr_diff_multiple_patchs, and get_pr_multi_diffs.
  • Added a regression test intended to ensure the shared diff-processing module no longer imports PyGithub’s RateLimitExceededException.
File summaries
File Description
pr_agent/algo/pr_processing.py Removes unused PyGithub import and unreachable rate-limit exception handlers in the shared diff path.
tests/unittest/test_pr_processing_core.py Adds regression coverage for project-level rate-limit propagation and import-boundary enforcement.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread tests/unittest/test_pr_processing_core.py
@Tiancheng-Xu

Copy link
Copy Markdown
Contributor Author

/agentic_review

@qodo-code-review

qodo-code-review Bot commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Code Review by Qodo

Grey Divider

Sorry, something went wrong

We weren't able to complete the code review on our side. Please try again manually by commenting /agentic_review on this PR.

Grey Divider

Qodo Logo

@IsmaelMartinez IsmaelMartinez left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Thanks for claiming #3139 and turning the direct option round within the hour. The tests pinning project-level RateLimitExceeded propagation through all three shared entry points are exactly the guard this removal needed, and the full AST walk answers Copilot's note.

@IsmaelMartinez
IsmaelMartinez merged commit 34c6592 into The-PR-Agent:main Sep 7, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dead PyGithub rate-limit handlers in the shared diff path

3 participants