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-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2b1f3a8093c1c664310da48c09ebf0dc1d5cf0627f9c25f18bf9e73531bcb05b |
|
MD5 | d0127477533429eab1445682341b77ac |
|
BLAKE2b-256 | e009de8c0954966218342ab50506c2e6f079bab2a034782cd58ec7dc7920d3dc |