superlinear-ai / poetry-cookiecutter

🍪 Poetry Cookiecutter is a modern Cookiecutter template for scaffolding Python packages and apps
GNU Affero General Public License v3.0
252 stars 37 forks source link

`Error: Invalid task: 'app'` for Python 3.12 app project #236

Closed vanolucas closed 6 months ago

vanolucas commented 6 months ago

Error

The error occurs when running poe lint or poe test on a Python 3.12 app project.

⬢ [Docker] ❯ poe lint
Poe the Poet - A task runner that works well with poetry.
version 0.25.1

Error: Invalid task: 'app'. Task definition must include exactly one task key from {'expr', 'shell', 'script', 'switch', 'sequence', 'ref', 'cmd'}

Steps to reproduce

Tested inside WSL2 on Windows 11 version 23H2.

Delete all existing poetry-cookicutter Docker containers and images.

Clone the repo to a local folder:

git clone git@github.com:radix-ai/poetry-cookiecutter.git

Open it with VSCode:

code .

Run VSCode command: Dev Containers: Rebuild Without Cache and Reopen in Container.

The poetry-cookiecutter dev container builds and opens.

Once completely initialized, open VSCode's bash terminal: Terminal: Create New Terminal.

Scaffold a new Python 3.12 app project using cruft:

cruft create -f https://github.com/radix-ai/poetry-cookiecutter

Choose the following cookiecutter values. Here reported in the generated .cruft.json:

{
  "template": "https://github.com/radix-ai/poetry-cookiecutter",
  "commit": "8ab7ee0accff3b9cb0e470bfc925858fc04d1e97",
  "checkout": null,
  "context": {
    "cookiecutter": {
      "project_type": "app",
      "project_name": "My App",
      "project_description": "A Python app that reticulates splines.",
      "project_url": "https://github.com/user/my-app",
      "author_name": "John Smith",
      "author_email": "john@example.com",
      "python_version": "3.12",
      "development_environment": "strict",
      "with_conventional_commits": "1",
      "with_fastapi_api": "0",
      "with_typer_cli": "0",
      "continuous_integration": "GitHub",
      "private_package_repository_name": "",
      "private_package_repository_url": "",
      "__docker_image": "python:$PYTHON_VERSION-slim",
      "__docstring_style": "NumPy",
      "__project_name_kebab_case": "my-app",
      "__project_name_snake_case": "my_app",
      "_template": "https://github.com/radix-ai/poetry-cookiecutter"
    }
  },
  "directory": null
}

Exit the dev container and close VSCode.

Copy the scaffolded project to another local folder:

cd ..
cp -r poetry-cookiecutter/my-app ./

Navigate to the scaffolded project folder and open it with VSCode:

cd my-app/
code .

Build the project's dev container: run VSCode command: Dev Containers: Rebuild Without Cache and Reopen in Container.

Once completely initialized, open VSCode's bash terminal: Terminal: Create New Terminal.

Init a git repo:

git init

Try to run code linting:

poe lint

Try to run tests:

poe test
spalster commented 6 months ago

Hi, @vanolucas. Looks like the problem is the app task definition in pyproject.toml. The sequence task that is part of the app task is defined as [[tool.poe.tasks.lint.sequence]] which should be [[tool.poe.tasks.app.sequence]]. Changing that line should fix the issue immediately.