fix: use tomli to parse toml file, prevent decode error for new toml syntax#910
fix: use tomli to parse toml file, prevent decode error for new toml syntax#910
Conversation
|
Hi @PTank, thanks for opening this. If I understand you correctly: this is a limitation in Specifically, it looks like a variant of this: uiri/toml#270 Switching to |
|
P.S.: Do you have a full |
Yes, and the toml last pypi update is 2020
I already tested it with a switch for the < 3.11, but we do not reach 100% coverage without tools like lines like: import sys
if sys.version_info >= (3, 11):
import tomllib
else:
import tomli as tomllib
[project]
dependencies = [
"flask==2.0.1"
]
[tool.other]
must_work = ["test", {"work" = true}] # toml.decoder.TomlDecodeError: Not a homogeneous array
must_work_too = ["test", {"work" = true, other_list = []}] # IndexError: list index out of rangeI did not add this to the tests, because I did not want to test toml or tomli input here |
|
Hi, for the lint error, maybe a change in # 547
result: dict[Dependency, list[VulnerabilityResult]] = {} |
|
Ah, don't worry about that -- I fixed that in another PR that hasn't landed yet. It's not related to these changes at all 🙂 |
|
Thanks @PTank! |
Signed-off-by: William Woodruff <william@trailofbits.com>
Why:
If the pyproject.toml contain some new syntax ak the dictionnary inside a list, the actual toml lib used by pip audit fail to parse the line and raise
IndexErrorExample who not work with
tomllibrary.How:
Change with
tomliandtomli_wfor the dump part.