Fix TypeError when iterating over 0 search results#583
Open
DuncanDHall wants to merge 1 commit intojjjake:masterfrom
Open
Fix TypeError when iterating over 0 search results#583DuncanDHall wants to merge 1 commit intojjjake:masterfrom
DuncanDHall wants to merge 1 commit intojjjake:masterfrom
Conversation
Scrape can result in `j` where `count: 0, total: None` resulting in: `TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'`
cclauss
reviewed
Apr 7, 2023
Comment on lines
+156
to
158
| num_found = int(j['total'] or 0) | ||
| if not self._num_found: | ||
| self._num_found = num_found |
Contributor
There was a problem hiding this comment.
It would be awesome if we had an empty search test case that failed with the current code and passed with the proposed code.
The GitHub Actions tests have been updated so another push to the pull request should pass all GitHub Actions.
Please remove line 155 and then...
Suggested change
| num_found = int(j['total'] or 0) | |
| if not self._num_found: | |
| self._num_found = num_found | |
| num_found = num_found or int(j['total'] or 0) | |
| self._num_found = self._num_found or num_found |
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.
Scrape can result in
jwhere'count': 0, 'total': Noneresulting in:TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'