ci: add ruff lint with F821/F811 rules#44
Open
joshbouncesecurity wants to merge 1 commit intoknostic:masterfrom
Open
ci: add ruff lint with F821/F811 rules#44joshbouncesecurity wants to merge 1 commit intoknostic:masterfrom
joshbouncesecurity wants to merge 1 commit intoknostic:masterfrom
Conversation
Adds a ruff lint step to the test workflow with two rules: F821 (undefined name) and F811 (redefined unused name). Python won't report an undefined name until that code path executes, so a missing import or typo can ship undetected. F821 + F811 catch that statically with zero false positives and no style noise. Lint runs before pytest so CI fails fast on missing imports. Also fixes a pre-existing F821 in core/analyzer.py: the analyze() function called tracker.add_prior_usage() without defining tracker locally; replaced with get_global_tracker() to match the pattern used elsewhere in the file. Refs #16 (item 2).
Contributor
Author
Manual verification
|
Contributor
Author
Local test resultsRan the configured ruff rules locally on Windows from this branch. Commands run: Output: Outcome:
|
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
Adds a ruff lint step to the test workflow with two rules:
F821(undefined name) andF811(redefined unused name). Python won't report an undefined name until that code path executes, so a missing import can ship undetected. F821 + F811 catch that statically with zero false positives and no style noise.Configured to run before pytest so CI fails fast on missing imports.
Verified clean against
upstream/masterbaseline after fixing one pre-existing violation:libs/openant-core/core/analyzer.py:393—analyze()calledtracker.add_prior_usage(...)without definingtrackerlocally. Replaced withget_global_tracker().add_prior_usage(...)to match the pattern already used elsewhere in the same file (e.g. line 489). This is a real bug — the line wouldNameErrorat runtime whenever resuming with non-zero prior token usage.Addresses item 2 from #16 (does not close the issue).
Test plan
ruff check .exits 0 on a clean checkout (verified locally).