nat-n / poethepoet

A task runner that works well with poetry.
https://poethepoet.natn.io/
MIT License
1.4k stars 58 forks source link

Must have tasks listed in `pyproject.toml` for `include = /path/to/tasks.toml` to work #50

Closed relsunkaev closed 2 years ago

relsunkaev commented 2 years ago

How to reproduce

With the following setup

pyproject.toml

[tool.poe]
include = "./tasks.toml"

tasks.toml

[tool.poe.tasks]
foo = { cmd = "echo bar }

Run

poe foo

Output

Traceback (most recent call last):
  File "/Users/.../bin/poe", line 8, in <module>
    sys.exit(main())
  File "/Users/.../poethepoet/__init__.py", line 32, in main
    result = app(cli_args=sys.argv[1:])
  File "/Users/.../poethepoet/app.py", line 44, in __call__
    self.config.load(self.ui["project_root"])
  File "/Users/.../poethepoet/config.py", line 113, in load
    self._load_includes(self._project_dir)
  File "/Users/.../poethepoet/config.py", line 250, in _load_includes
    self._merge_config(tomli.load(file), include_path)
  File "/Users/.../poethepoet/config.py", line 284, in _merge_config
    own_tasks = self._poe["tasks"]
KeyError: 'tasks'

Workaround

Add an empty tasks inline table to the config

pyproject.toml

[tool.poe]
include = "./tasks.toml"
tasks = {}

Environment

Software Version
OS macOS 12.1
Python 3.9.9
Poetry 1.1.12
Poethepoet 0.12.1
nat-n commented 2 years ago

Hi @relsunkaev,

Thanks for the detailed bug report. Looks like I missed an edge case!

We should have a fix out for this shortly.

nat-n commented 2 years ago

Et voilà https://github.com/nat-n/poethepoet/releases/tag/v0.12.2