-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
Radon reports ValueError: invalid interpolation syntax
when use pytest log format with $()d
. But pytest official documentation uses $()d
:
_pytest.logging — pytest documentation
DEFAULT_LOG_FORMAT = "%(levelname)-8s %(name)s:%(filename)s:%(lineno)d %(message)s"
How to reproduce
pyproject.toml
:
[tool.pytest.ini_options]
log_format = "%(asctime)s %(process)d %(levelname)s %(name)s:%(filename)s:%(lineno)d %(message)s"
$ radon
Traceback (most recent call last):
File "/workspace/.venv/bin/radon", line 8, in <module>
sys.exit(main())
File "/workspace/.venv/lib/python3.9/site-packages/radon/__init__.py", line 10, in main
from radon.cli import program, log_error
File "/workspace/.venv/lib/python3.9/site-packages/radon/cli/__init__.py", line 90, in <module>
_cfg = FileConfig()
File "/workspace/.venv/lib/python3.9/site-packages/radon/cli/__init__.py", line 45, in __init__
self.file_cfg = self.file_config()
File "/workspace/.venv/lib/python3.9/site-packages/radon/cli/__init__.py", line 85, in file_config
config.read_dict(FileConfig.toml_config())
File "/usr/local/lib/python3.9/configparser.py", line 754, in read_dict
self.set(section, key, value)
File "/usr/local/lib/python3.9/configparser.py", line 1204, in set
super().set(section, option, value)
File "/usr/local/lib/python3.9/configparser.py", line 894, in set
value = self._interpolation.before_set(self, section, option,
File "/usr/local/lib/python3.9/configparser.py", line 402, in before_set
raise ValueError("invalid interpolation syntax in %r at "
ValueError: invalid interpolation syntax in "{'log_format': '%(asctime)s %(process)d %(levelname)s %(name)s:%(filename)s:%(lineno)d %(message)s'}" at position 17
To avoid this issue, it requires to replace log_format
in pyproject.toml
as following:
- log_format = "%(asctime)s %(process)d %(levelname)s %(name)s:%(filename)s:%(lineno)d %(message)s"
+ log_format = "%(asctime)s %(process)s %(levelname)s %(name)s:%(filename)s:%(lineno)s %(message)s"
radon version: 6.0.1
$ radon --version
6.0.1
When rollback to radon 5.1.0, it can be avoided.
Tested python version: 3.9.16
$ python --version
Python 3.9.16
OS info:
$ cat /etc/os-release
NAME="Amazon Linux"
VERSION="2"
ID="amzn"
ID_LIKE="centos rhel fedora"
VERSION_ID="2"
PRETTY_NAME="Amazon Linux 2"
ANSI_COLOR="0;33"
CPE_NAME="cpe:2.3:o:amazon:amazon_linux:2"
HOME_URL="https://amazonlinux.com/"
kieran-ryan
Metadata
Metadata
Assignees
Labels
No labels