Metadata-Version: 2.1
Name: cfel-pylint-checkers
Version: 1.1.4
Summary: Additional checkers for pylint that are used by the FS-CFEL-1 team
Home-page: https://gitlab.desy.de/cfel-sc-public/cfel-pylint-checkers
License: GPL-3.0-or-later
Author: Philipp Middendorf
Author-email: philipp.middendorf@desy.de
Requires-Python: >=3.8,<3.11
Classifier: License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Dist: pylint (>=2.14.0,<3.0.0)
Project-URL: Repository, https://gitlab.desy.de/cfel-sc-public/cfel-pylint-checkers
Description-Content-Type: text/markdown

# 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:

```python
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:

```python
mydict = { "foo": 3 }

print(mydict.get("bar"))
```

Which produces `None` if the key doesn’t exist. You can even specify a default value:

```python
mydict = { "foo": 3 }

print(mydict.get("bar", 0))
```

Mutating use of `operator[]` is, of course, still possible. This is *fine*:

```python
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](https://www.tango-controls.org/), specifically its Python adaptation [PyTango](https://pytango.readthedocs.io/en/stable/). 

For instance, the following mismatch between the `dtype_in` of a command and its actual type annotation is caught:

```python
from tango.server import Device, command

class MyDevice(Device):
    @command(dtype_in=int)
    def mycommand(self, argument: str) -> None:
        pass
```

