pylint throws an error when adding logging-format-style as a configuration option in pyproject.toml and trying to lint my project
[tool.pylint.messages_control]
disable = """
bad-continuation,
wrong-import-position,
invalid-name,
line-too-long,
too-few-public-methods,
import-outside-toplevel
"""
[tool.pylint.logging]
load-plugins = """
pylint.extensions.docparams,
pylint.extensions.mccabe
"""
logging-format-style="fstr"
pyproject.toml file[tool.pylint.logging]logging-format-style = "fstr"pylint name_of_package --rcfile pyproject.tomlan exception is thrown
optparse.OptionValueError: option logging-format-style: invalid value: '"fstr"', should be in ['old', 'new', 'fstr']
This happens when also trying 'fstr', """fstr""" and other combinations of spaces and quotes
traditional parsing and logging format style set to fstring
pylint 2.4.4
astroid 2.3.3
Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 05:52:31)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
Thanks for the report!
I'm no longer able to reproduce this with the unreleased version installed from the master branch, namely:
pylint 2.5.0-dev1
astroid 2.4.0
Python 3.6.5 (default, May 7 2018, 10:07:07)
[GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)]
I can confirm it reproduces with pylint 2.4.4 and astroid 2.3.3 though, so it must have been fixed in the master branch at some point.
I'm running up against this issue using 2.5.0
root@0cbb5d29b695:/workspace# pip install pylint
Collecting pylint
Downloading pylint-2.5.0-py3-none-any.whl (324 kB)
|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 324 kB 707 kB/s
Collecting astroid<=2.5,>=2.4.0
Downloading astroid-2.4.0-py3-none-any.whl (327 kB)
|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 327 kB 13.1 MB/s
Collecting mccabe<0.7,>=0.6
Downloading mccabe-0.6.1-py2.py3-none-any.whl (8.6 kB)
Collecting toml>=0.7.1
Downloading toml-0.10.0-py2.py3-none-any.whl (25 kB)
Collecting isort<5,>=4.2.5
Downloading isort-4.3.21-py2.py3-none-any.whl (42 kB)
|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 42 kB 3.1 MB/s
Collecting six~=1.12
Downloading six-1.14.0-py2.py3-none-any.whl (10 kB)
Collecting wrapt~=1.11
Downloading wrapt-1.12.1.tar.gz (27 kB)
Collecting lazy-object-proxy==1.4.*
Downloading lazy_object_proxy-1.4.3-cp38-cp38-manylinux1_x86_64.whl (58 kB)
|鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅鈻堚枅| 58 kB 7.4 MB/s
Building wheels for collected packages: wrapt
Building wheel for wrapt (setup.py) ... done
Created wheel for wrapt: filename=wrapt-1.12.1-cp38-cp38-linux_x86_64.whl size=81482 sha256=68e87adab33d5bac4526b9d899c96188a2e20844471406e07b3010c05b53f982
Stored in directory: /root/.cache/pip/wheels/5f/fd/9e/b6cf5890494cb8ef0b5eaff72e5d55a70fb56316007d6dfe73
Successfully built wrapt
Installing collected packages: six, wrapt, lazy-object-proxy, astroid, mccabe, toml, isort, pylint
Successfully installed astroid-2.4.0 isort-4.3.21 lazy-object-proxy-1.4.3 mccabe-0.6.1 pylint-2.5.0 six-1.14.0 toml-0.10.0 wrapt-1.12.1
root@0cbb5d29b695:/workspace# pylint --version
pylint 2.5.0
astroid 2.4.0
Python 3.8.1 (default, Feb 2 2020, 08:37:37)
[GCC 8.3.0]
root@0cbb5d29b695:/workspace# cat pylintrc
[MASTER]
extension-pkg-whitelist=cassandra
[MESSAGES CONTROL]
# disabling:
# - duplicate-code because there's no way to ignore it inline
disable=R0801
[LOGGING]
logging-format-style=fstr
root@0cbb5d29b695:/workspace# pylint
Traceback (most recent call last):
File "/usr/local/bin/pylint", line 8, in <module>
sys.exit(run_pylint())
File "/usr/local/lib/python3.8/site-packages/pylint/__init__.py", line 22, in run_pylint
PylintRun(sys.argv[1:])
File "/usr/local/lib/python3.8/site-packages/pylint/lint/run.py", line 300, in __init__
linter.load_config_file()
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 787, in load_config_file
self.global_set_option(option, value)
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 668, in global_set_option
self._all_options[opt].set_option(opt, value)
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 880, in set_option
value = _validate(value, optdict, optname)
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 273, in _validate
return _call_validator(_type, optdict, name, value)
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 254, in _call_validator
return VALIDATORS[opttype](optdict, option, value)
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 242, in <lambda>
"choice": lambda opt, name, value: _choice_validator(opt["choices"], name, value),
File "/usr/local/lib/python3.8/site-packages/pylint/config.py", line 196, in _choice_validator
raise optparse.OptionValueError(msg % (name, value, choices))
optparse.OptionValueError: option logging-format-style: invalid value: 'fstr', should be in ['old', 'new']
@PCManticore do you prefer to reopen this bug or create a new one with @inhumantsar content ?
I can confirm that even when using the updated pylint and astroid packages, the issue with pyproject.toml still persists
pylint 2.5.0
astroid 2.4.0
Python 3.7.4 (v3.7.4:e09359112e, Jul 8 2019, 14:54:52)
[Clang 6.0 (clang-600.0.57)]
same toml setup as above
I'm also experiencing this issue with pylint 2.5.0 with both python 3.6 and 3.8. I'm configuring pylint from .pylintrc only as so:
[FORMAT]
max-line-length=120
[LOGGING]
logging-format-style=fstr
and then just running pylint mypackage.
Please check the last release note from http://pylint.pycqa.org/en/latest/whatsnew/2.5.html
logging-format-fstyle=fstr is now gone and you need to use logging-fstring-interpolation instead if you want to have f-string interpolation supported with logging.
@PCManticore thanks for pointing me to that. I should have looked there myself.
Most helpful comment
Please check the last release note from http://pylint.pycqa.org/en/latest/whatsnew/2.5.html
logging-format-fstyle=fstris now gone and you need to uselogging-fstring-interpolationinstead if you want to havef-stringinterpolation supported with logging.