You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add a pyproject.toml to the project with this content:
[tool.pylint.master]
fail-under = 9.4
When running pylint, it aborts with an exception.
Full traceback:
Traceback (most recent call last):
File "/test/virtualenv/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
File "/test/virtualenv/lib/python3.8/site-packages/pylint/__init__.py", line 24, in run_pylint
PylintRun(sys.argv[1:])
File "/test/virtualenv/lib/python3.8/site-packages/pylint/lint/run.py", line 333, in __init__
linter.load_config_file()
File "/test/virtualenv/lib/python3.8/site-packages/pylint/config/option_manager_mixin.py", line 313, in load_config_file
for option, value in parser.items(section):
File "/usr/lib/python3.8/configparser.py", line 859, in items
return [(option, value_getter(option)) for option in orig_keys]
File "/usr/lib/python3.8/configparser.py", line 859, in <listcomp>
return [(option, value_getter(option)) for option in orig_keys]
File "/usr/lib/python3.8/configparser.py", line 855, in <lambda>
value_getter = lambda option: self._interpolation.before_get(self,
File "/usr/lib/python3.8/configparser.py", line 395, in before_get
self._interpolate_some(parser, option, L, value, section, defaults, 1)
File "/usr/lib/python3.8/configparser.py", line 412, in _interpolate_some
p = rest.find("%")
AttributeError: 'float' object has no attribute 'find'
Current behavior
With fail-under = 9 the behaviour is as expected, using a floating point value leads to an exception.
Thank you for the report and the analysis. Would you mind making a pull request for it as you already did most of the work ? (I don't think there will be edge cases :) )
siehar
pushed a commit
to siehar/pylint
that referenced
this issue
May 28, 2021
* Handle floats when parsing pyproject.toml (#4518)
* [pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
Co-authored-by: Markus Siebenhaar <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Steps to reproduce
Add a pyproject.toml to the project with this content:
When running pylint, it aborts with an exception.
Full traceback:
Current behavior
With
fail-under = 9
the behaviour is as expected, using a floating point value leads to an exception.Expected behavior
Floating point values should work.
pylint --version output
Result of
pylint --version
output:But also tested with latest release version 2.8.2 and it also happens there.
Reason
The issue seems to come from here: https://github.com/PyCQA/pylint/blob/master/pylint/config/option_manager_mixin.py#L281
Floats coming from the TOML parser aren't handled here which later on confuses
ConfigParser
.A simple fix would be to change
isinstance(value, int)
toisinstance(value, (int, float))
.I tried that fix and it works though I'm not sure if there are some weird edge cases where this breaks.
The text was updated successfully, but these errors were encountered: