poetry-core
poetry-core copied to clipboard
More specific error message when project name contains disallowed characters
Context
Recently I was working on a project using poetry, and ended up in a state where I was unable to use poetry build
, due to getting a "No file/folder found for package <project_name>
" error repeatedly, despite the folder structure etc being correct to what poetry expects to see
After a bunch of google searching and diving into the source code myself, I was able to see that the cause was that the project name I was using was "molpro-dirman", containing an illegal -
character. Once I sussed this out and changed all the project naming to use an underscore instead, everything worked nominally.
In this change I've added an error trap and more specific error message when this case arises for the next person :slightly_smiling_face:
Changes
- Catch specific subcase where dir not found due to substitution of disallowed chars
- Log more specific error message in this case
Checklist
- [x] Added tests for changed code. (n/a / minor error trapping code change only)
- [x] Updated documentation for changed code. (n/a / minor change / self-documenting changes)
You've misunderstood something. Not only are hyphens allowed in project names, this very project has a hyphen in its project name: https://github.com/python-poetry/poetry-core/blob/e33e9d1613338f045b55cae1a7953dec7d86f311/pyproject.toml#L2
Also your pull request has nothing much to do with what you've reported: a hyphen is not an uppercase underscore!
Perhaps you could usefully include module._name
in the existing exception, I don't think we need a new exception.
Wants a unit test case.