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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | e13aef49b37729d70239b55af047efab75828cd8504619cf6a6bd1a203dec714 |
|
MD5 | 6044ffaaddb7a806298dff6b6687b8f6 |
|
BLAKE2b-256 | d4c4f61802c1b7531eed3ac32b4b07aaf8294fd6327ff57e382e59d89825b2b6 |
Hashes for cfel_pylint_checkers-1.0.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 5f3e40a23f44d2f7001cbfb4f8360fd48ce6a2c1fd06ac15452cc90d9fa4a7b5 |
|
MD5 | e9f3a8a1054113ae729b4bb91b03c740 |
|
BLAKE2b-256 | 235e5e0458ea42d79d28a3001fd33699a35228434cf59adec2f0fa436a532e3f |