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
Built Distribution
Hashes for cfel-pylint-checkers-1.0.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7965eec8c4cc226a55026e16f9a69abd80735d4bb128ec27bd309dee5dae6d98 |
|
MD5 | 6b54cd749b5e3ab8e0c9f68fc32d82b5 |
|
BLAKE2b-256 | a41f686ab6650461684a046d04597b39c6cdea12b2e1a35fed3085c45ce3e6ef |
Hashes for cfel_pylint_checkers-1.0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a6b021e1e08f24a3a6d338c4fba43289f7525c5489cee75f2b0e64d76b4816ce |
|
MD5 | 0a867d26d1aed2fab53dd7f8608f6c51 |
|
BLAKE2b-256 | cce3b35dc9952c671f34600e6c99e399b91aa5c64a72e37e78ab3ff04a8e087a |