Skip to main content

Use Set Literals Instead of Sets from Lists


ImportanceReview GuidanceRequires Scanning Tool
LowMerge Without ReviewNo

This codemod converts Python set constructions using literal list arguments into more efficient and readable set literals. It simplifies expressions like set([1, 2, 3]) to {1, 2, 3}, enhancing both performance and code clarity.

Our changes look like this:

-x = set([1, 2, 3])
+x = {1, 2, 3}

If you have feedback on this codemod, please let us know!


Why is this codemod marked as Merge Without Review?

We believe this change is safe and will not cause any issues.

Codemod Settings