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.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | beb44a84f0a66ff4e9765ae92a4d58e6fc5f324d35898ab2a34f88c1cc11bc75 |
|
MD5 | 8cf5622eafff7445fd8434bb43e6c470 |
|
BLAKE2b-256 | f532affe542033969e91583ad86d2d0770b1c8f38e8efb971478e980960a5fb6 |
Hashes for cfel_pylint_checkers-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 96af9c4334b9a5209a9e918bc0c1f5f69ee49485014bee4bab27ba01d3444803 |
|
MD5 | f6a6d34e71f5c74094c3e133e66b1141 |
|
BLAKE2b-256 | 7928d0bca215e3a38c31538eee71b7cfb5ab4644feb996903d90ef15cb4a026e |