unnecessary-literal-within-dict-call (C418) (dict() 调用中存在不必要的字面量)
Derived from the flake8-comprehensions linter. (源自 flake8-comprehensions linter。)
修复总是可用的。
作用
检查以不必要的字典字面量或字典推导式作为参数的 dict()
调用。
为什么这不好?
将字典字面量或推导式包装在 dict()
调用中是不必要的,因为字面量或推导式语法已经返回一个字典。
示例
建议改为
修复安全性
This rule's fix is marked as unsafe, as it may occasionally drop comments when rewriting the call. In most cases, though, comments will be preserved. (此规则的修复被标记为不安全,因为它在重写调用时有时会删除注释。但在大多数情况下,注释将被保留。)