Skip to content

R504 false positive when variable is a function parameter #133

@jakkdl

Description

@jakkdl
  • Date you used flake8-return: 2023-03-16
  • flake8-return version used, if any: 1.2.0
  • Python version, if any: 3.10.9
  • Operating System: Linux

Description

def foo(a):
    if ...:
        a = 2
    return a
$ flake8 foo.py --select=R
foo.py:4:12: R504 unnecessary variable assignment before return statement.

variables that are function parameters should not be treated as unnecessary, cursory skim of https://github.com/afonasev/flake8-return/blob/master/flake8_return/mixins/unnecessary_assign.py looks like it doesn't look at FunctionDef or AsyncFunctionDef at all which explains it.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions