Fix flag_and_ignore_files_over_max_size inconsistent return value and docstring#2184
Open
prajakta128 wants to merge 1 commit into
Open
Conversation
… docstring
The function docstring claimed to return the remaining files queryset
within the file size limit, but .update() actually returns an integer
count of updated rows.
The caller in scanpipe/pipes/scancode.py already re-filters manually:
resource_qs.filter(~Q(status=flag.IGNORED_BY_MAX_FILE_SIZE))
proving the original return value was misleading.
Fix: explicitly return the flagged_count integer and update the
docstring to accurately describe the return value.
Add regression tests to verify the return type and that files
are correctly flagged with IGNORED_BY_MAX_FILE_SIZE status.
Signed-off-by: Prajakta Kamble <prajuu2812@gmail.com>
cd2a7aa to
4cd77ad
Compare
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.
What
Fix
flag_and_ignore_files_over_max_sizeinscanpipe/pipes/flag.pywhich had a misleading docstring and an implicit return value.Why
The docstring claimed the function would: > "return all other files within the file size limit"
But
.update()returns an integer (count of updated rows), not a queryset. This is inconsistent and confusing for anyone reading the code.Evidence that the return value was misleading — the caller in
scanpipe/pipes/scancode.pyignores the return value and manuallyre-filters:
resource_qs.filter(~Q(status=flag.IGNORED_BY_MAX_FILE_SIZE))
Fix
.update()result toflagged_countvariableflagged_countclearlyFiles changed
scanpipe/pipes/flag.py— fix return value + docstringscanpipe/tests/pipes/test_flag.py— add two regression tests