poetry-core icon indicating copy to clipboard operation
poetry-core copied to clipboard

More specific error message when project name contains disallowed characters

Open MolarFox opened this issue 1 year ago • 3 comments

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)

MolarFox avatar Mar 14 '23 16:03 MolarFox

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
No Duplication information No Duplication information

sonarqubecloud[bot] avatar Mar 14 '23 16:03 sonarqubecloud[bot]

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!

dimbleby avatar Mar 14 '23 17:03 dimbleby

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.

dimbleby avatar Mar 14 '23 17:03 dimbleby