DET004warningProauto-fixable

list-set-dedup

Using list(set(...)) for deduplication scrambles element order

Applies to: Python

Why this matters

Converting a list to a set and back removes duplicates, but also scrambles the order of elements. If you need to preserve order while removing duplicates, use dict.fromkeys() or a loop that tracks seen items.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, DET004 includedstablestack explain DET004

DET004 is part of the Pro rule set. See pricing — the free tier ships 24 checks with no signup.

False positive in your codebase? Suppress a single line with # noqa: DET004