fix: replace improper None comparisons and remove duplicate dict key #2049
+3
−4
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