When enforcing code style, my team prefers using a dict literal instead of the dict() function call:
c = { "a": 1 } // good
d = {} // good
e = dict() // bad
Can Black (or any linter or code formatter for python) do this?
When enforcing code style, my team prefers using a dict literal instead of the dict() function call:
c = { "a": 1 } // good
d = {} // good
e = dict() // bad
Can Black (or any linter or code formatter for python) do this?
Maintainer of black here :wave:
Black cannot do this as this would be an AST unsafe transformation. It's not certain whether Black will gain AST unsafe features down the road, but it's unlikely IMO.
Instead you can use pylint with code R1735 enabled or use flake8-comprehensions with code C408 enabled.