Skip to content

Pylint does not respect false values for boolean config options in toml files #8460

@GrimzEcho

Description

@GrimzEcho

Bug description

When pylint loads its configuration from a .toml file, it treats the mere presence of a key as enabling that flag or option, without regard to its actual value.

For instance, setting from-stdin = false in a toml config will cause pylint to attempt to read from stdin. Setting exit-zero = false will cause pylint to always exit with code 0 even if there are errors or warnings.

The only way to disable the flag is to comment out the line. This is directly at odds with the example configuration provided in the documentation (https://pylint.readthedocs.io/en/latest/user_guide/configuration/all-options.html) which has many examples of option = false.

This same behavior seems to happen with pylintrc configuration files as well, but I only did some basic testing.

Configuration

# example 1:
[tool.pylint.main]
from-stdin = false
exit-zero = false

# example 2:
[tool.pylint.main]
# from-stdin = false
exit-zero = false

# example 3:
[tool.pylint.main]
# from-stdin = false
# exit-zero = false

Command used

pylint test.py; echo $?
# test.py
import datetime

Pylint output

# example 1
# hangs because it is expecting input from stdin ... must be killed with ctrl-c


# example 2
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:0: W0611: Unused import datetime (unused-import)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
0


# example 3
************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:1:0: W0611: Unused import datetime (unused-import)
------------------------------------------------------------------
Your code has been rated at 0.00/10 (previous run: 0.00/10, +0.00)
20

Expected behavior

Examples 1 and 2 should produce the same output as example 3

Pylint version

pylint 2.17.0
astroid 2.15.0
Python 3.7.3 (default, Oct 31 2022, 14:04:00) 
[GCC 8.3.0]

OS / Environment

Debian 10

Additional dependencies

None

Metadata

Metadata

Assignees

Labels

ConfigurationRelated to configurationGood first issueFriendly and approachable by new contributorsHacktoberfestNeeds PRThis issue is accepted, sufficiently specified and now needs an implementation

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions