How can I disable a pylint message via pyproject.toml for a specific file?

137 Views Asked by At

I'm encountering the too-many-instance-attributes pylint error in multiple files and I want to disable this message only for one file my_project/runner/runner.py. Is it possible to do this in the poetry pyproject.toml file?

pylint my_project

************* Module my_project.models_vi.config.hostname
my_project\models_vi\config\hostname.py:67:0: R0902: Too many instance attributes (9/7) (too-many-instance-attributes)
************* Module my_project.models_vi.config.port_descr
my_project\models_vi\config\port_descr.py:92:0: R0902: Too many instance attributes (11/7) (too-many-instance-attributes)
************* Module my_project.runner.runner
my_project\runner\runner.py:22:0: R0902: Too many instance attributes (9/7) (too-many-instance-attributes)
1

There are 1 best solutions below

0
dkasa On

There is the Per File Ignore Plugin where you can ignore files with:

# Example from the plugin repository.

[tool.pylint.'MESSAGES CONTROL']
per-file-ignores = [
    "/folder_1/:missing-function-docstring,W0621,W0240,C0115",
    "file.py:C0116,E0001"
]

Or you can add a comment at the start of the module like so if you don't want or can't use plugins.

# runner.py
# pylint: disable=R0902