Are you seeing failure while running flake8
?
C408 Unnecessary (dict/list/tuple) call - rewrite as a literal.
One of the main purposes of flake8
is to improve the list/set/dict comprehensions in Python.
If this issue is related to the dictionary, you have to rewrite the Python dictionary.
Let’s say you have following line of codes.
data = dict(a=1, b=2)
print(data)
Output
{'a': 1, 'b': 2}
If you execute it, you will get the expected output. But, when you run the flake8
, you will get the following error.
C408 Unnecessary (dict/list/tuple) call - rewrite as a literal
And the suggestion is to rewrite the Python dictionary literal.
Rewrite "dict([])" as "{}"
To solve this issue, change the above Python code as,
data = {"a": 1, "b": 2}
print(data)
Output
{'a': 1, 'b': 2}
There will be no functionality impact. It is just part code quality improvement.
Like Python dictionary, this issue can also be occurred for Python list or tuple.
Hope this helps you to solve your problem. If you are still facing any flake8
issue, let me know by commenting below. I will try my best to help you.