-
Notifications
You must be signed in to change notification settings - Fork 128
Open
Description
When there's an array under tool
section in pyproject.toml, parsing fails.
Example
This example contains array under tool. Then you can call radon to do analysis.
[tool.radon]
exclude = "test_*.py"
cc_min = "B"
[[tool.foo]]
key = "value1"
[[tool.foo]]
key = "value2"
The above looks like this in json format and I believe it is syntactically correct:
{
"tool":{
"radon":{
"exclude":"test_*.py",
"cc_min":"B"
},
"foo":[
{
"key":"value1"
},
{
"key":"value2"
}
]
}
}
As data for foo
is list, not dict, you get an exception.
Traceback
Traceback (most recent call last):
File "DIR/radon/env/bin/radon", line 8, in <module>
sys.exit(main())
^^^^^^
File "DIR/radon/radon/__init__.py", line 10, in main
from radon.cli import program, log_error
File "DIR/radon/radon/cli/__init__.py", line 90, in <module>
_cfg = FileConfig()
^^^^^^^^^^^^
File "DIR/radon/radon/cli/__init__.py", line 45, in __init__
self.file_cfg = self.file_config()
^^^^^^^^^^^^^^^^^^
File "DIR/radon/radon/cli/__init__.py", line 85, in file_config
config.read_dict(FileConfig.toml_config())
File "/opt/homebrew/Cellar/[email protected]/3.12.11/Frameworks/Python.framework/Versions/3
.12/lib/python3.12/configparser.py", line 734, in read_dict
for key, value in keys.items():
^^^^^^^^^^
AttributeError: 'list' object has no attribute 'items'
Solution
Fixing this issue is easy as you should just ignore everything under tool
that is not related to radon.
Metadata
Metadata
Assignees
Labels
No labels