fix: Report integer count in 'Experiencing problems' status log#1860
Merged
fix: Report integer count in 'Experiencing problems' status log#1860
Conversation
Walrus precedence made `failed_requests := X - Y > 0` parse as `failed_requests := ((X - Y) > 0)`, so the status log printed '... True failed requests ...' instead of the actual count.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1860 +/- ##
==========================================
- Coverage 92.41% 92.40% -0.01%
==========================================
Files 158 158
Lines 11009 11009
==========================================
- Hits 10174 10173 -1
- Misses 835 836 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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
The walrus operator at
_basic_crawler.py:1656binds less tightly than>, sofailed_requests := X - Y > 0was parsed asfailed_requests := ((X - Y) > 0)per PEP 572. As a result,failed_requestswas assigned aboolinstead of the integer difference, and the periodic status log emitted:instead of the actual count.
Fix
Move the parentheses so
:=captures the integer subtraction and> 0sits outside.Regression test
Added
test_status_message_reports_failed_request_count, which directly invokes_crawler_state_taskwith a mocked_statistics.stateand a separate_previous_crawler_state, asserting the rendered message contains the integer count3, notTrue.