refactor: code style and linting cleanup#79
Open
igoropaniuk wants to merge 4 commits intoqualcomm-linux:mainfrom
Open
refactor: code style and linting cleanup#79igoropaniuk wants to merge 4 commits intoqualcomm-linux:mainfrom
igoropaniuk wants to merge 4 commits intoqualcomm-linux:mainfrom
Conversation
EnsureDirectoryExists, PrintBigWarning, PrintBigError, reflect, and CalcCRC32 were defined identically (or near-identically) in both files. Keeping two copies means any bug fix or improvement has to be applied twice, and they have already drifted apart (different except clauses, debug prints in only one copy). utils.py now owns the single authoritative implementation of each function. PrintBigWarning and PrintBigError accept an optional log_func parameter (default: print) so msp.py can continue routing output through device_log without duplicating the banner strings. msp.py exposes thin wrappers that bind log_func=device_log, leaving all call sites unchanged. ptool.py imports directly since it already used print. The ptool.py-only debug prints in CalcCRC32 (which called the ptool-private HexPrettyPrint) are dropped as they were not present in msp.py and are not part of the algorithm. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Unsorted imports make it harder to spot duplicates and missing stdlib/third-party separation at a glance. isort enforces a consistent, deterministic order (stdlib → third-party → local) with one import per line. Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Use ruff [1] linter to find/address reported issues: - Unused imports (F401): remove codecs, math, time, traceback, xml.dom.minidom, Comment/Element/SubElement/tostring, and the unused reflect re-export from utils in msp.py. - Undefined name (F821): log_debug was never defined in ptool.py; the single call site in HexPrettyPrint is replaced with print(). - Identity comparisons (E711/E714): replace `== None` with `is None` and `not x is None` with `x is not None`. - Boolean comparisons (E712): replace `== True` / `== False` checks with plain truthiness tests or `not` prefix. - Unused variables (F841): drop dead assignments in both files (parser_inst, part, CurrentSector, P, x, header_crc_offset, LastPartitionBeginsAt, FileNotFoundShowWarning, SectorsRemaining, FileFound, size). - Semicolon style (E702/E703): split compound `stmt ; stmt` lines onto separate lines and remove trailing semicolons throughout ptool.py (GPT/MBR/EBR byte-packing loops). [1] https://github.com/astral-sh/ruff Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Enforces a consistent, machine-verified code style using black tool [1] across all Python sources so that future diffs reflect only logic changes and not incidental whitespace or quoting differences. [1] https://github.com/psf/black Signed-off-by: Igor Opaniuk <igor.opaniuk@oss.qualcomm.com>
Contributor
Author
It seems that Repolinter is misconfigured, as this appears to be a check for Node.js (???) |
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.
Applies automated code-quality tooling across all Python sources.
No functional changes.
CalcCRC32, PrintBigWarning, PrintBigError) into a shared utils.py
dead variables, boolean/identity comparisons, trailing semicolons)
reported by ruff