-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Description
-
I am on the latest Poetry version.
-
I have searched the issues of this repo and believe that this is not a duplicate.
-
If an exception occurs when executing a command, I executed it again in debug mode (
-vvvoption). -
OS version and name: Ubuntu 16.04 (Xenial)
-
Poetry version: 1.1.0
-
Link of a Gist with the contents of your pyproject.toml file: https://gist.github.com/amaralbf/f5a2d2f24b72235f5f8ff53a3182c272
Issue
First of all, thank you so much for putting so much effort into this project! It's been my favorite tool for packaging and managing my projects' dependencies.
The issue I've encountered occurs when I try to execute the poetry init command and:
- a
pyproject.tomlalready exists (and has no poetry sections); - and one or more
--dependencyor--dev-dependencyare specified.
If I run poetry init without specifying any --dependency or --dev-dependency, it works as expected.
Example
Command: poetry init -n --dependency numpy -vvv
- (I get exact same Stack trace if I run the command interactively)
Output:
This command will guide you through creating your pyproject.toml config.
Stack trace:
11 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/console_application.py:131 in run
129│ parsed_args = resolved_command.args
130│
→ 131│ status_code = command.handle(parsed_args, io)
132│ except KeyboardInterrupt:
133│ status_code = 1
10 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py:120 in handle
118│ def handle(self, args, io): # type: (Args, IO) -> int
119│ try:
→ 120│ status_code = self._do_handle(args, io)
121│ except KeyboardInterrupt:
122│ if io.is_debug():
9 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/clikit/api/command/command.py:171 in _do_handle
169│ handler_method = self._config.handler_method
170│
→ 171│ return getattr(handler, handler_method)(args, io, self)
172│
173│ def __repr__(self): # type: () -> str
8 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/cleo/commands/command.py:92 in wrap_handle
90│ self._command = command
91│
→ 92│ return self.handle()
93│
94│ def handle(self): # type: () -> Optional[int]
7 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/init.py:160 in handle
158│ if self.option("dependency"):
159│ requirements = self._format_requirements(
→ 160│ self._determine_requirements(self.option("dependency"))
161│ )
162│
6 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/init.py:319 in _determine_requirements
317│ return requires
318│
→ 319│ requires = self._parse_requirements(requires)
320│ result = []
321│ for requirement in requires:
5 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/init.py:380 in _parse_requirements
378│
379│ try:
→ 380│ cwd = self.poetry.file.parent
381│ except RuntimeError:
382│ cwd = Path.cwd()
4 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/commands/command.py:10 in poetry
8│ @property
9│ def poetry(self):
→ 10│ return self.application.poetry
11│
12│ def reset_poetry(self): # type: () -> None
3 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/console/application.py:69 in poetry
67│ return self._poetry
68│
→ 69│ self._poetry = Factory().create_poetry(Path.cwd())
70│
71│ return self._poetry
2 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/factory.py:33 in create_poetry
31│ io = NullIO()
32│
→ 33│ base_poetry = super(Factory, self).create_poetry(cwd)
34│
35│ locker = Locker(
1 ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/core/factory.py:32 in create_poetry
30│ def create_poetry(self, cwd=None): # type: (Optional[Path]) -> Poetry
31│ poetry_file = self.locate(cwd)
→ 32│ local_config = PyProjectTOML(path=poetry_file).poetry_config
33│
34│ # Checking validity
PyProjectException
[tool.poetry] section not found in /home/amaralbf/dev/issue_poetry_init/pyproject.toml
at ~/.local/pipx/venvs/poetry/lib/python3.8/site-packages/poetry/core/pyproject/toml.py:55 in poetry_config
51│ def poetry_config(self): # type: () -> Optional[TOMLDocument]
52│ if self._poetry_config is None:
53│ self._poetry_config = self.data.get("tool", {}).get("poetry")
54│ if self._poetry_config is None:
→ 55│ raise PyProjectException(
56│ "[tool.poetry] section not found in {}".format(self._file)
57│ )
58│ return self._poetry_config
59│
Thanks again!