Skip to content
Sarj Code Standards

no-redundant-local-alias

Remove a local alias used only for its matching keyword argument.

Why

An extra local binding makes readers trace two names for one value when the keyword already communicates its role.

Fix

Apply the safe fix where offered; otherwise pass the original local to the matching keyword and remove the unannotated alias after review.

Examples

Before — flagged Initialize the original after the completed guard
case.py
def render(enabled):
if not enabled:
return None
item = make_item()
payload = item
return build(payload=payload)
After — preferred Pass the fresh original directly
case.py
def render(enabled):
if not enabled:
return None
item = make_item()
return build(payload=item)
Before — flagged A safe builtin mapping return
case.py
def render(item):
payload = item
return dict(payload=payload)
After — preferred Return the original local in the mapping
case.py
def render(item):
return dict(payload=item)
Before — flagged A closed private dict wrapper preserves the original value
case.py
def render(item):
def _record(value):
payload = value
return dict(payload=payload)
return _record(item)
After — preferred The same keyword receives the original parameter
case.py
def render(item):
def _record(value):
return dict(payload=value)
return _record(item)
Autofix output
case.py
def render(item):
def _record(value):
return dict(payload=value)
return _record(item)
Before — flagged The keyword supplies the role
case.py
def render(item):
payload = item
consume(payload=payload)
After — preferred Pass the original local
case.py
def render(item):
consume(payload=item)