fix: resolve UnboundLocalError in apm prune crashing all prune operations#283
Merged
danielmeppiel merged 2 commits intomainfrom Mar 13, 2026
Merged
Conversation
…boundLocalError Co-authored-by: danielmeppiel <51440732+danielmeppiel@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] [66955159225] Fix failing GitHub Actions workflow integration tests
fix: resolve UnboundLocalError in Mar 13, 2026
apm prune crashing all prune operations
Contributor
There was a problem hiding this comment.
Pull request overview
This PR removes a redundant local import in the apm prune command, relying on the existing module-level import for get_lockfile_path.
Changes:
- Remove the nested
from ..deps.lockfile import get_lockfile_pathimport inside theif pruned_keys:block.
Merged
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.
apm prunefailed unconditionally withcannot access local variable 'get_lockfile_path' where it is not associated with a value, breaking all prune-related integration tests.Description
A duplicate
from ..deps.lockfile import get_lockfile_pathinside theprune()function body shadowed the module-level import. Python treats any name assigned (including viaimport) within a function as local throughout the entire function scope — causing anUnboundLocalErrorwhen the name was referenced earlier in the same function, before the inner import statement was reached.Fix: remove the redundant inner import; the module-level import is sufficient.
Type of change
Testing
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.