Open
Description
Description
TOML 1.0.0 supports mixed type arrays, but the toml
library does not, leading to parsing errors.
Steps to Reproduce
This is a valid poetry pyproject.toml
working without issues:
[tool.poetry]
name = "dummy-project"
version = "0.1.0"
description = ""
authors = ["John Doe <[email protected]>"]
readme = "README.md"
packages = [{include = "dummy_project"}]
include = [
# having both a string and an object here seems to trigger the problem:
"CHANGELOG.md",
{ path = "tests", format = "sdist" },
# ----
]
[tool.poetry.dependencies]
python = "^3.8"
pyproject-parser = "^0.8.0"
[build-system]
requires = ["poetry-core"]
build-backend = "poetry.core.masonry.api"
Now let's parse it:
import pyproject_parser
pyproject_parser.PyProject.load("pyproject.toml")
Actual result:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/pyproject_parser/__init__.py", line 176, in load
config = dom_toml.load(filename)
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/dom_toml/__init__.py", line 217, in load
return loads(
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/dom_toml/__init__.py", line 171, in loads
return toml.loads( # type: ignore[return-value]
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/toml/decoder.py", line 511, in loads
ret = decoder.load_line(line, currentlevel, multikey,
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/toml/decoder.py", line 778, in load_line
value, vtype = self.load_value(pair[1], strictly_valid)
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/toml/decoder.py", line 880, in load_value
return (self.load_array(v), "array")
File "/local/home/a.pirogov/.cache/pypoetry/virtualenvs/dummy-project-oiKNdZ99-py3.8/lib/python3.8/site-packages/toml/decoder.py", line 1002, in load_array
a[b] = a[b] + ',' + a[b + 1]
IndexError: list index out of range
Expected result:
No exception.
Reproduces how often:
Always
Version
- Python: 3.8
- pyproject-parser: 0.8
Installation source
PyPI
Other Additional Information:
I think the simplest fix would be to switch from the toml
to the tomli
library, which parses the file just fine.