Repository navigation
refactor(web): remove unreachable resp checks from the async request loop - #2085
Merged
Merged
Conversation
…loop `resp` in `_request_with_session` is declared `None` and never assigned, so `if resp is not None: return resp` never runs. The trailing `return response` after the try/finally is unreachable too: the try body always returns or raises. `raise last_error` is kept as is. Co-Authored-By: Claude <svc-devxp-claude@slack-corp.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #2085 +/- ##
==========================================
+ Coverage 84.78% 84.79% +0.01%
==========================================
Files 118 118
Lines 14132 14129 -3
==========================================
- Hits 11982 11981 -1
+ Misses 2150 2148 -2 ☔ View full report in Codecov by Harness. |
mwbrooks
approved these changes
Nov 26, 2026
mwbrooks
left a comment
Member
There was a problem hiding this comment.
✅ Thanks @WilliamBergamin, nice tidy-up and the PR body made the dead paths easy to verify.
|
|
||
| if resp is not None: | ||
| return resp | ||
| raise last_error # type: ignore[misc] |
Member
There was a problem hiding this comment.
thought: After 100 response-driven retries (say a handler that keeps retrying 429s), last_error is still None here and this raises a TypeError, while the sync client returns its last resp. Not from this PR, but it could make a good follow-up to bring the two in line.
9 of 16 tasks
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
This pull request removes unreachable code from the async
_request_with_sessionretry loop.respis declaredNoneand never assigned, soif resp is not None: return respnever runs.return responseafter thetry/finallyis unreachable too: thetrybody always returns or raises.raise last_erroris kept exactly as is. The sync client,webhook,audit_logs, andscimall assignresp, so their checks are live and untouched.No behavior change, no generated code changes.
Testing
Nothing in
slack_sdk/web/async_internal_utils.pyassignsresp(grep -n "resp�" slack_sdk/web/async_internal_utils.py). The existing async web client and retry tests cover the loop; mypy accepts the function ending inraise.Category
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.🤖 Generated with Claude Code