Skip to content

manual-list-copy rule should prefer lst.copy() over list(lst) to be more explicit #21593

@injust

Description

@injust

Summary

On https://docs.astral.sh/ruff/rules/manual-list-copy/, the description says:

When creating a copy of an existing list using a for-loop, prefer list or list.copy instead.

And the example suggests:

original = list(range(10000))
filtered = list(original)

In Zed, Ruff surfaces this messaging:

Use list or list.copy to create a copy of a list


lst.copy() should be preferred over list(lst) so the intention is more explicit (copying vs converting a non-list iterable to a list).

I think the example should be updated to use list.copy(), and either:

  • Order list.copy() before list(), or
  • Only suggest list.copy()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions