Skip to content

Separate check for possibly unused arguments if locals() is used #4912

Open
@Stealthii

Description

@Stealthii

Current problem

  • I have a long list of keywords to a method, that I want to define for type hints
  • I need to pass these to another method as a dictionary, using locals()
  • pylint detects possibly unused variables, but not arguments

Desired solution

  • pylint should extend the logic used around unused argument and variable definitions to consider arguments as potentially unused as well

Additional context

Here is an example function that makes use of local scope variables and arguments.

def example(arg_a='a', arg_b='b'):  # unused-argument
    """An example function."""
    var_c = 'c'  # potentially-unused-variable
    return locals()  # {'arg_a': 'a', 'arg_b': 'b', 'var_c': 'c'}

Metadata

Metadata

Assignees

No one assigned

    Labels

    C: undefined-variableIssues related to 'undefined-variable' checkFalse Positive 🦟A message is emitted but nothing is wrong with the codeNeeds investigation 🔬A bug or crash where it's not immediately obvious what is happenning

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions