fix: replace improper None comparisons and remove duplicate dict key - #2049
Open
shbhmexe wants to merge 1 commit into
Open
fix: replace improper None comparisons and remove duplicate dict key#2049shbhmexe wants to merge 1 commit into
shbhmexe wants to merge 1 commit into
Conversation
Replace == None/!= None with is None/is not None (PEP 8 E711) and fix duplicate dictionary key in test helper function. Changes: - test_pipeline_id.py: Change == None to is None (line 56) - test_improve_runner.py: Remove duplicate 'references' key (line 185) - test_improve_runner.py: Change == None to is None (line 210) - test_xen_importer_v2.py: Change == None to is None (line 102) These changes improve code quality and fix a bug where a duplicate dictionary key caused the first value to be silently overwritten. Signed-off-by: shbhmexe <shubhushukla586@gmail.com>
TG1999
requested changes
Nov 27, 2025
| "references": list(VulnerabilityReference.objects.all()), | ||
| "advisories": list(Advisory.objects.all()), | ||
| "packages": list(Package.objects.all()), | ||
| "references": list(VulnerabilityReference.objects.all()), |
Author
There was a problem hiding this comment.
The 'references' key was duplicated in this dictionary (lines 182 and 185). I removed the second occurrence as it was redundant and overwriting the first one.
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 PR fixes code quality issues identified during a repository audit, focusing on Python best practices (PEP 8) and code correctness.
Changes Made
1. Fixed Improper None Comparisons (PEP 8 E711)
Replaced
== Noneand!= Nonewithis Noneandis not Nonein test files:vulnerabilities/tests/pipelines/test_pipeline_id.py(line 56)vulnerabilities/tests/test_improve_runner.py(line 210)vulnerabilities/tests/pipelines/v2_importers/test_xen_importer_v2.py(line 102)Reasoning: PEP 8 recommends using
isoris notwhen comparing toNonerather than equality operators. This is both a style issue and can prevent bugs since__eq__can be overridden.2. Fixed Duplicate Dictionary Key
Removed duplicate
"references"key intest_improve_runner.py(line 185):"references"defined on both line 182 and 185VulnerabilitySeverity), line 185 should use the key"severity"Reasoning: This is a functional bug where the first
"references"value was being silently overwritten by the duplicate key.Impact
Testing
All changes are in test files. The affected tests validate:
The changes maintain the same test behavior - they just use the correct Python idioms for None comparisons and fix the dictionary key issue.
Checklist