v2 - Catch problems with [tool.poetry.scripts] entries #8898
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Pull Request Check List
Related-to: #issue-number-here (partially)
A continuation of: #7756 since the author seems to have left the chat
More informative error messages when scripts are misspecified.
Main difference is that the error message has been updated with more information, and the no-context information ("too many/too few values to unpacked") is removed.
The previously proposed error message was still a bit too cryptic, so I added separate cases for "too many colons" vs "colons absent" because they are different problems - with no colons, one might be trying to specify a whole python module because their script runs module-level code. I added a hint in that case to just wrap it in a
main
function with a suggestion of how to changepyproject.toml
. The other case is just a warning that there are too many colons and shows what the current value is.So for "no colons" with a pyproject.toml like:
The error message is:
and for a "too many colons" with a pyproject.toml like:
the error message is:
I also removed script specifiers like
"foo.bar:baz.bin"
because they were misleading about what the test handled.It seems like the ultimate thing that needs to happen here is to add regex to the JSON schema file so that editors alert people before the time they try and install a package - https://github.com/python-poetry/poetry-core/blob/main/src/poetry/core/json/schemas/poetry-schema.json - but that's not for me today ;)