fix: resolve F821 undefined name violations, remove per-file-ignores#129
Merged
ericchansen merged 1 commit intomasterfrom Mar 23, 2026
Merged
fix: resolve F821 undefined name violations, remove per-file-ignores#129ericchansen merged 1 commit intomasterfrom
ericchansen merged 1 commit intomasterfrom
Conversation
- jaguar.py: initialize current_structure and temp_eigenvectors before loop - macromodel.py: initialize bonds/angles/torsions/atoms/current_structure and col_nums/elements/row_num before their respective loops - test_linear_algebra.py: replace dead code in skipped test with pass - pyproject.toml: remove entire per-file-ignores section (zero remaining) Closes #128 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR removes all remaining Ruff F821 (undefined name) violations by making variable initialization explicit in a few legacy parsers/tests, allowing the repository-wide removal of Ruff per-file-ignores for F821.
Changes:
- Initialize previously conditionally-assigned locals in
JaguarOut.import_file()andMacroModel.structures/MacroModelLog.hessianso Ruff can prove they’re defined. - Remove incomplete/undefined-reference code from a skipped legacy unittest (
test_last) to eliminateF821. - Delete the entire Ruff
[tool.ruff.lint.per-file-ignores]section frompyproject.toml.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
q2mm/parsers/jaguar.py |
Initializes current_structure / temp_eigenvectors before the parsing loop to satisfy F821. |
q2mm/parsers/macromodel.py |
Initializes structure-accumulator locals in .structures and Hessian parsing locals in .hessian to satisfy F821. |
test/test_linear_algebra.py |
Removes undefined-name references from an already-skipped test to eliminate F821. |
pyproject.toml |
Removes Ruff per-file-ignores now that F821 issues are resolved. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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
Resolves all 33 F821 (undefined name) violations across 3 files and removes the entire
per-file-ignoressection frompyproject.toml.Changes
q2mm/parsers/jaguar.py— Initializecurrent_structureandtemp_eigenvectorsbefore the parsing loop. These were assigned inside conditional blocks but used outside them; works at runtime but ruff couldn't verify the control flow.q2mm/parsers/macromodel.py— Initializebonds,angles,torsions,atoms,current_structurebefore the main loop inMacroModel.structures, andcol_nums,elements,row_numbefore the word loop inMacroModelLog.hessian. Same scoping pattern.test/test_linear_algebra.py— Replace dead code intest_last(already@unittest.skip) withpass. The method referencedlogandmin_hessianthat were never defined — genuinely incomplete refactoring.pyproject.toml— Remove entire[tool.ruff.lint.per-file-ignores]section. Also removed 3 stale entries (gaussian.py,mol2.py,structures.py) that had zero violations.Verification
ruff check .— all checks passedruff format --check— all files formattedCloses #128