flake8-comprehensions: Incorrect C408 rule warning for dict with keyword arguments

The C408 rule seems to fail on a dict with keyword arguments, but from the description of the rule, it should not fail.

$ cat scratch.py 
a = dict(one=1, two=2, three=3)

$ flake8 --version
3.8.2 (flake8-bugbear: 20.1.4, flake8-comprehensions: 3.2.2, mccabe: 0.6.1, pycodestyle: 2.6.0, pyflakes: 2.2.0) CPython 3.8.2
on Darwin

$ flake8 ~/Library/Preferences/PyCharmCE2019.3/scratches/scratch.py 
scratch.py:1:5: C408 Unnecessary dict call - rewrite as a literal.

About this issue

  • Original URL
  • State: closed
  • Created 4 years ago
  • Comments: 15 (8 by maintainers)

Commits related to this issue

Most upvoted comments

I only just discovered this great tool, but I’d prefer C408 to be split into 2 distinct rules. One for empty items and one for dict with keyword-only arguments. That way one could be disabled without affecting the other.

I’ve restored the check for dict() being called with keyword-only arguments in #282, because I also missed it! Released in version 3.3.0.