Poetry >= 1.5.0 incompatibility
Matesanz opened this issue · comments
System
- Pycodestyle version :
2.11.0
- Poetry version: Poetry (version 1.6.1)
- Python version: Python 3.11.5 [GCC 10.2.1 20210110] on linux
- OS version and name: Ubuntu 20.04
- pyproject.toml:
Linked to:
Description
👉 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
ℹ️ 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
.
Pycodestyle does not support project files as you've found. We will not be adding support either.