Skip to main content

Additional checkers for pylint that are used by the FS-CFEL-1 team

Project description

cfel-pylint-checkers

Installation

Just pip install cfel-pylint-checkers should suffice. Then you can enable the appropriate checkers as plugins by editing your .pylintrc file, extending the load-plugins line. For example:

load-plugins=cfel_pylint_checkers.no_direct_dict_access

Checkers

no-direct-dict-access

This disallows the use of dictionary access using the [] operator for reading. Meaning, this is no longer allowed:

mydict = { "foo": 3 }

print(mydict["bar"])

As you can see, this code produces an error, since we’re accessing "bar" but the mydict dictionary only contains the key "foo". You have to use .get to make this safe:

mydict = { "foo": 3 }

print(mydict.get("bar"))

Which produces None if the key doesn’t exist. You can even specify a default value:

mydict = { "foo": 3 }

print(mydict.get("bar", 0))

Mutating use of operator[] is, of course, still possible. This is fine:

mydict = { "foo": 3 }

mydict["bar"] = 4

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

cfel-pylint-checkers-1.0.tar.gz (14.2 kB view hashes)

Uploaded Source

Built Distribution

cfel_pylint_checkers-1.0-py3-none-any.whl (26.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