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,cfel_pylint_checkers.tango_command_dtype
Checkers
no-direct-dict-access
Enable with:
load-plugins=cfel_pylint_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
tango-command-dtype
Enable with:
load-plugins=cfel_pylint_checkers.tango_command_dtype
This checker tests for various error conditions related to the hardware controls system Tango, specifically its Python adaptation PyTango.
For instance, the following mismatch between the dtype_in
of a command and its actual type annotation is caught:
from tango.server import Device, command
class MyDevice(Device):
@command(dtype_in=int)
def mycommand(self, argument: str) -> None:
pass
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.1.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 913209142c13f0daf980050fd802f05ac5e5fc739b2551e775864e3417f1e76f |
|
MD5 | d00ecf249df6be2177166aa8fd8ff61c |
|
BLAKE2b-256 | 8d577c90df36ed770b31556389538eab37be9c59c1df73196928b3ae1d572989 |
Hashes for cfel_pylint_checkers-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1df8052ae6006484f1bbf327990863b77efac2c5391dcc951f17c796fe95ca75 |
|
MD5 | 0477b70a5c259078d3871e2d15312d40 |
|
BLAKE2b-256 | 167582482a3d657f31d4625f551e784ccc3a8323525d7e0d637af1481f0fd0cd |