ruff icon indicating copy to clipboard operation
ruff copied to clipboard

Encourage dict/list creation through constructor

Open twoertwein opened this issue 10 months ago • 1 comments

a = {} # or a = dict()
a["a"] = 1
a["b"] = 2

b = []
b.append(1)
b.append(2)

should be

a = {"a": 1, "b": 2}
b = [1, 2]

I thought there was already a rule in ruff for that but ruff check --select ALL didn't point them out

twoertwein avatar Apr 18 '24 18:04 twoertwein

Also should cover .extend calls for lists, and .update calls for sets and dicts.

Skylion007 avatar Apr 20 '24 19:04 Skylion007