Skip to main content

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

cfel_pylint_checkers-1.1.0.tar.gz (16.1 kB view details)

Uploaded Source

Built Distribution

cfel_pylint_checkers-1.1.0-py3-none-any.whl (17.0 kB view details)

Uploaded Python 3

File details

Details for the file cfel_pylint_checkers-1.1.0.tar.gz.

File metadata

  • Download URL: cfel_pylint_checkers-1.1.0.tar.gz
  • Upload date:
  • Size: 16.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.2 CPython/3.10.9 Linux/5.15.94

File hashes

Hashes for cfel_pylint_checkers-1.1.0.tar.gz
Algorithm Hash digest
SHA256 5ed9eb24f4a8e47470431b6d6652c88cb8609fd6b02023b0332399def0d3243e
MD5 640e75703088ceb5e85a9a43c4a9f1a8
BLAKE2b-256 e900fffe9a6a70700714d8b399860a426a367d185fcc15e1d3cd5f154ba84bff

See more details on using hashes here.

File details

Details for the file cfel_pylint_checkers-1.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for cfel_pylint_checkers-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 50f59eab7a22f7c3f9bd2602f64da6ae80276ba429e62132b01a723f9a7c2ca1
MD5 5f6f5eb55b1656ec4385cbb8cde5e7dc
BLAKE2b-256 25e05b8d9b24bc3f4ad0e6578b7cd56c815ef4903bc105ae35471e219fd7c7a2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page