Skip to content

Sacrimento/flake8-get-chaining

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

flake8-get-chaining

A flake8 plugin finding likely bugs when chaining dict.get calls

CI Code style PyPI - Python Version PyPI - Version

flake8-get-chaining plugin checks for chained dict.get calls and makes sure valid defaults are provided.

Installation


Install from pip with:

$ pip install flake8-get-chaining

It will then automatically be run as part of flake8; you can check it has been picked up with:

$ flake8 --version
5.0.4 (flake8-get-chaining: 0.1.0, mccabe: 0.7.0, pycodestyle: 2.9.1, pyflakes: 2.5.0) CPython 3.10.9 on Linux

List of warnings


DGC1001: Missing default argument when chaining dict.get
This warning is emitted when dict.get calls are chained, and no default was provided.

Example: my_dict.get("foo").get("bar")

DGC1002: Invalid default argument when chaining dict.get
This warning is emitted when dict.get calls are chained, and the default value is
invalid (i.e not a dict nor an identifier)

Example: my_dict.get("foo", "bar").get("baz")