Skip to content

Fix 10 bugs identified by ruff: undefined name, variable shadowing, and import organization#39

Merged
zhubonan merged 3 commits into
developfrom
copilot/scan-repository-for-bugs
Mar 6, 2026
Merged

Fix 10 bugs identified by ruff: undefined name, variable shadowing, and import organization#39
zhubonan merged 3 commits into
developfrom
copilot/scan-repository-for-bugs

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Feb 15, 2026

Bug Fixes for aiida-abacus Repository

Summary

Successfully identified and fixed all 10 linter errors in the aiida-abacus repository. All fixes have been validated and security scanned.

Bugs Identified and Fixed:

  • Initial exploration and bug identification
  • HIGH PRIORITY: Fix F821 - Missing TrajectoryData import in calculations.py (line 180)
    • Changed TrajectoryData to orm.TrajectoryData to match usage pattern in parsers
  • Fix PLR1704 - Variable shadowing in orb_group.py (line 516) - pseudo_path parameter redefined
    • Renamed context manager variable to pseudo_folder to avoid shadowing the parameter
  • Fix RUF059 - Unused variable in base.py (line 255) - cutoff_rho unpacked but never used
    • Prefixed with underscore _cutoff_rho to mark as intentionally unused
  • Fix RUF022 - Unsorted __all__ list in protocols/generator.py (line 24)
    • Alphabetically sorted the list to comply with isort-style conventions
  • Fix PLC0415 - Move imports to top-level in common/init.py (2 instances)
    • Moved collections import to top of file
    • Moved PortNamespace import to top of file
  • Removed unnecessary noqa comments (workflows/band.py and workflows/base.py)
    • PLC0415 warnings are not triggered by ruff 0.4.3 (the version used by the project)
    • The noqa comments were unnecessary and have been removed
  • Run tests to verify all fixes work correctly
    • Verified all modified modules import successfully
    • Verified TrajectoryData spec works correctly
    • Verified recursive_merge function works with collections import
    • Verified all is properly sorted and exports work
  • Request code review - No issues found
  • Run security scan with CodeQL - No vulnerabilities found

Security Summary

✅ No security vulnerabilities identified by CodeQL scanner

Files Modified

  1. src/aiida_abacus/calculations.py - Fixed undefined TrajectoryData
  2. src/aiida_abacus/group/orb_group.py - Fixed variable shadowing
  3. src/aiida_abacus/workflows/base.py - Fixed unused variable, removed noqa comments
  4. src/aiida_abacus/protocols/generator.py - Fixed unsorted all
  5. src/aiida_abacus/common/__init__.py - Fixed imports location
  6. src/aiida_abacus/workflows/band.py - Removed noqa comments

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: zhubonan <33688599+zhubonan@users.noreply.github.com>
Copilot AI changed the title [WIP] Add code bug scanning for repository Fix 10 bugs identified by ruff: undefined name, variable shadowing, and import organization Feb 15, 2026
Copilot AI requested a review from zhubonan February 15, 2026 12:23
@zhubonan zhubonan marked this pull request as ready for review March 6, 2026 12:12
Copy link
Copy Markdown
Collaborator

@zhubonan zhubonan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread src/aiida_abacus/workflows/band.py Outdated
# Using sumo interface
try:
from aiida_abacus.common.sumo_kpath import kpath_from_sumo_v2
from aiida_abacus.common.sumo_kpath import kpath_from_sumo_v2 # noqa: PLC0415
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@copilot remove the noqa statement as they are not enabled

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed in commit b1ad68e. The PLC0415 rule is not triggered by ruff 0.4.3 (the project's version), so the noqa comments were unnecessary.

Copilot AI requested a review from zhubonan March 6, 2026 12:20
@zhubonan zhubonan merged commit bb303aa into develop Mar 6, 2026
3 checks passed
@zhubonan zhubonan deleted the copilot/scan-repository-for-bugs branch April 23, 2026 02:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants