Skip to content

Confusing error msg if path in "packages" doesn't exist #2139

@geckon

Description

@geckon
  • I have searched the issues of this repo and believe that this is not a duplicate.
  • I have searched the documentation and believe that my question is not covered.

Feature Request

Could poetry please handle typos/errors in tool.poetry.packages better?

If you make a typo or another error in specifying packages to include into your package and the modules specified in pyproject.toml don't exist, you'll get a very user-unfriendly message:

$ poetry build
Building dummy_package (1.49.1)

[IndexError]
list index out of range

Let's say you have a package called dummy_package and in it you have python modules dummy1 and dummy2 you want to include into the package. Then you'd like to put this into your pyproject.toml:

packages = [
    { include = "dummy1" },
    { include = "dummy2" },    
]

If instead you make a mistake and have e.g. this there:

packages = [
    { include = "dumny1" },
    { include = "dumny2" },    
]

You ge tthe above mentioned error which is very confusing and not helpful at all.

The error happens because you mention a module that doesn't exist in your project directory. The actual error happens in method check_elements() (specifically on line 37 in current master) in poetry/masonry/utils/package_include.py but I think it might be detectable in poetry/masonry/utils/include.py where it tries to expand the path. Maybe there it could issue a warning or something?

The issue was mentioned e.g. in #1247 but that issue is closed and I'd like this to get a little more attention as I spent a few hours debugging this.

Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/error-handlingBad error messages/insufficient error handling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions