Repository navigation
Remove four no-op self-assignments - #2247
Open
Dhairya-007 wants to merge 1 commit into
Open
Dhairya-007 wants to merge 1 commit into
Dhairya-007 wants to merge 1 commit into
Conversation
Each of these is a statement of the form `x = x` where `x` is already a local (a parameter in three cases, and a name assigned two lines earlier in the fourth), so each one reads the name and writes the same value straight back: - `libcloud/common/nttcis.py:2040` `mapping = mapping` - `libcloud/compute/drivers/gridscale.py:367` `template = template` - `libcloud/compute/drivers/nttcis.py:1356` `plan = plan` - `libcloud/storage/drivers/s3.py:989` `response = response` Removing them is behaviour-preserving. They are the kind of line that costs a reader a moment to rule out as load-bearing, which is the only reason to bother. CI does not flag these because the pylint env runs `pylint -E`, and self-assigning-variable is W0127, a warning. `pylint -E --rcfile=./pyproject.toml` passes both before and after this change. `libcloud/common/cloudstack.py:184` is left alone deliberately: there the `command = command` is the body of an `if` branch that exists precisely to leave `command` untouched, so it is a placeholder rather than dead code and removing it would leave an empty block. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Remove four no-op self-assignments
Description
Four statements of the form
x = x, wherexis already a local, so each reads the name and writes the same value straight back:xislibcloud/common/nttcis.pymapping = mappingprocessor(mapping, name=None)libcloud/compute/drivers/gridscale.pytemplate = template_create_volume_from_template(...)libcloud/compute/drivers/nttcis.pyplan = planex_enable_snapshots(...)libcloud/storage/drivers/s3.pyresponse = responseresult_dict["response"]two lines aboveRemoving them is behaviour-preserving. There is no scope subtlety hiding here — in all four cases the name is a local before the statement runs, so the assignment cannot be shadowing or capturing anything. They are just lines that cost a reader a moment to rule out as load-bearing.
Why CI never flagged them: the
pylintenv runspylint -E, which reports errors only, andself-assigning-variableisW0127— a warning. So these are invisible to the current gate rather than tolerated by it.One I deliberately left in place:
libcloud/common/cloudstack.py:184also has acommand = command, but there it is the entire body of anifbranch that exists specifically to leavecommanduntouched while the sibling branches rewrite it:That one is a placeholder, not dead code, and deleting it would leave an empty block. Happy to turn it into a
passwith a short comment if you'd prefer the branch to say what it means, but that felt like a separate judgement call from removing dead lines, so I kept it out of this PR.Status
Done, ready for review.
Verification
Run with the versions pinned in
pyproject.toml'slintgroup (flake8 5.0.4, black 26.10.1, pylint 4.0.9):Checklist (tick everything that applies)
Claude Code assisted in writing this patch; I checked each statement's scope and ran the linting and tests above before opening it.