-
Notifications
You must be signed in to change notification settings - Fork 70
fix: use tomli to parse toml file, prevent decode error for new toml syntax #910
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 range I 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 <[email protected]>
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
IndexError
Example who not work with
toml
library.How:
Change with
tomli
andtomli_w
for the dump part.