Search code examples
pythonpylintpyproject.toml

When using Pylint, how to state a particular list of variables which are valid names with the pyproject.toml settings file


Running pylint on a file containing variables such as x or l will raise an error, though these variables might be meaningful in the context that they're in.

I could disable all such errors by adding the following to pyproject.toml:

[tool.pylint."MESSAGES CONTROL"]
disable = [ "invalid-name"]

But I would prefer to be able to instead explicitly state the variables that I would like to ignore.


Solution

  • To ignore pylint errors for particular variable names the good-names list can be set within pyproject.toml as follows:

    [tool.pylint."MESSAGES CONTROL"]
    good-names = [
        "x",
        "y",
    ]
    

    Which will make x and y valid variable names for pylint.