:point_right: Currently, when adding multiple sources to Poetry >= 1.5.0, all of them have the same section name[tool.poetry.source] (as you can see in the pyproject.toml below). So when trying to read that file with the default python ConfigParser Module an configparser.DuplicateSectionError exception is raised. ConfigParser is used by Pycodestyle to read the pyproject.toml file. Making them incompatible with Poetry.
In Poetry, sources are defined like this:
# pyproject.toml
[[tool.poetry.source]]
name = "PyPI"
priority = "primary"
[[tool.poetry.source]]
name = "torch_cpu"
url = "https://download.pytorch.org/whl/cpu"
priority = "supplemental"
So when running pycodestyle </path/to/file.py> --config=pyproject.toml we get this error:
$ pycodestyle main.py --config=pyproject.toml
Traceback (most recent call last):
File "/home/vscode/.pyenv/versions/3.11.5/bin/pycodestyle", line 8, in <module>
sys.exit(_main())
^^^^^^^
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pycodestyle.py", line 2636, in _main
style_guide = StyleGuide(parse_argv=True)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pycodestyle.py", line 2295, in __init__
options, self.paths = process_options(
^^^^^^^^^^^^^^^^
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pycodestyle.py", line 2593, in process_options
options = read_config(options, args, arglist, parser)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/site-packages/pycodestyle.py", line 2518, in read_config
config.read(cli_conf)
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/configparser.py", line 713, in read
self._read(fp, filename)
File "/home/vscode/.pyenv/versions/3.11.5/lib/python3.11/configparser.py", line 1086, in _read
raise DuplicateSectionError(sectname, fpname,
configparser.DuplicateSectionError: While reading from 'pyproject.toml' [line 49]: section '[tool.poetry.source]' already exists
:information_source: Using ConfiParser is not intended to read TOML files, but INI files, that may look similar but they are not the same. Using toml module should be preferred over configparser.
System
2.11.0
Linked to:
Description
:point_right: Currently, when adding multiple sources to
Poetry >= 1.5.0
, all of them have the same section name[tool.poetry.source]
(as you can see in thepyproject.toml
below). So when trying to read that file with the default python ConfigParser Module anconfigparser.DuplicateSectionError
exception is raised. ConfigParser is used by Pycodestyle to read thepyproject.toml
file. Making them incompatible with Poetry.In Poetry, sources are defined like this:
So when running
pycodestyle </path/to/file.py> --config=pyproject.toml
we get this error::information_source: Using
ConfiParser
is not intended to read TOML files, but INI files, that may look similar but they are not the same. Usingtoml
module should be preferred overconfigparser
.