Skip to content

False positive in PERF402 when append is more complex.  #5494

@bgianfo

Description

@bgianfo

The new rule PERF402 suggests to convert lists to trivial copies in cases where it's not really possible. Ideally the tool would not report such false positives.

If you're filing a bug report, please consider including the following information:

  • A minimal code snippet that reproduces the bug.
 # In this example you can't trivially convert this to a `list.copy` as the rule suggests.  
 for r in record_dict["values"]:
        list_of_stuff[r["other_value"]].append(r)
  • The command you invoked (e.g., ruff /path/to/file.py --fix), ideally including the --isolated flag.

    ruff --select=PERF402 example.py

  • The current Ruff settings (any relevant sections from your pyproject.toml).

    PERF ruleset is enabled

  • The current Ruff version (ruff --version).

    version = 0.0.276

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions