fix: code quality - variable typo, dead import, PEP 8 identity checks, unnecessary f-strings#993
fix: code quality - variable typo, dead import, PEP 8 identity checks, unnecessary f-strings#993BEAST04289 wants to merge 2 commits into
Conversation
… unnecessary f-strings - Fix misspelled variable pentalty -> penalty in gap_analysis.py (3 occurrences) - Remove unused import json as _json in cre_main.py - Use is None instead of == None per PEP 8 (6 occurrences across 5 files) - Strip unnecessary f-string prefixes from strings with no placeholders (production code only)
|
Caution Review failedAn error occurred during the review process. Please try again later. WalkthroughThis PR modernizes ChangesPython cleanup and correctness updates
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Pull request overview
This PR aims to apply code-quality cleanups across the Python codebase (typo fix, PEP 8 None identity checks, and removal of unnecessary f-strings) while keeping behavior unchanged.
Changes:
- Rename misspelled local variable
pentalty→penaltyin gap analysis scoring. - Replace
== Nonechecks withis Nonefor PEP 8 singleton comparisons across multiple modules. - Remove
fprefixes from strings that have no interpolation, and remove a purportedly-dead JSON import alias.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| application/web/web_main.py | Removes unnecessary f-strings in PostHog event names and one logger call. |
| application/utils/spreadsheet_parsers.py | Replaces == None with is None in parsing logic. |
| application/utils/oscal_utils.py | Replaces uuid == None with uuid is None in OSCAL conversion. |
| application/utils/gap_analysis.py | Fixes local variable typo (pentalty → penalty) in path scoring. |
| application/utils/external_project_parsers/parsers/export_format_parser.py | Replaces == None with is None in export-format parsing. |
| application/prompt_client/prompt_client.py | Removes unnecessary f-strings from logger messages. |
| application/database/inmemory_graph.py | Replaces == None with is None for graph cache check. |
| application/database/db.py | Replaces == None with is None and removes unnecessary f-strings in exception/log strings. |
| application/cmd/cre_main.py | Removes f-strings and removes import json as _json (but _json is still referenced later). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| from collections import deque | ||
| from typing import Any, Callable, Dict, List, Optional, Tuple, TYPE_CHECKING | ||
| import hashlib | ||
| import json as _json | ||
| from rq import Queue, job, exceptions | ||
| from sqlalchemy import not_ |
Summary
Code quality fixes found during a full codebase audit. All changes are zero-behavior-change.
Follows up on leftover items from #836 / #837 (which was scoped down to just the
get_by_tagsshadowing fix during rebase).Changes
Variable Typo Fix
pentalty→penaltyingap_analysis.py(3 occurrences, lines 100–102) — misspelled local variable fromget_path_score()Dead Import Removal
import json as _jsonremoved fromcre_main.py— imported but never referenced anywhere in the file (jsonis already imported on line 4)PEP 8:
== None→is None(6 occurrences across 5 files)Per PEP 8: comparisons to singletons like
Noneshould useis/is not, because==invokes__eq__which a custom class could override, whileischecks object identity — andNoneis a singleton, so identity is the correct check.Files:
spreadsheet_parsers.py(×2),oscal_utils.py,export_format_parser.py,inmemory_graph.py,db.pyUnnecessary f-string Prefixes (production code only)
Removed
fprefix from ~23 strings that contain no{}placeholders:web_main.py— 13 posthog event names + 1 logger calldb.py— 4 exception/log messagescre_main.py— 4 logger callsprompt_client.py— 2 logger callsTest files were intentionally left untouched to keep the diff focused.
Testing
python -m py_compile)pentalty,_json, or== Nonein the codebase