Skip to main content

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

Project description

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")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flake8_get_chaining-0.2.0.tar.gz (4.4 kB view hashes)

Uploaded Source

Built Distribution

flake8_get_chaining-0.2.0-py3-none-any.whl (4.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page