Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Turn spaces in project name to underscore. #6085

Closed
wants to merge 1 commit into from
Closed

Turn spaces in project name to underscore. #6085

wants to merge 1 commit into from

Conversation

Ninzero
Copy link

@Ninzero Ninzero commented Jul 28, 2022

Pull Request Check List

Currently, if the project name you typed contains whitespaces, the package name will also contain whitespaces. For example:

poetry new "New Project"

will cause test file contain:

from new project import __version__

which will cause error. In this case, we should automatically change project name to new_project.

I know that set --name argument can solve this problem. But I think maybe this process can be automated.

  • Added tests for changed code.

I have not include a tests for this PR. Mainly because I have not figured out a suitable testing method, also because this is a draft PR. If anyone have good idea on how to test, please help, thanks.

  • Updated documentation for changed code.

No documentation change required for this PR.

Copy link
Member

@neersighted neersighted left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change as-is is much too specific and hardcoded to the particular issue you sought to solve. We should likely normalize all project names during poetry new (e.g. see the canonicalize_name() function in packaging.utils that was most recently discussed in #6022), or reject them outright if they don't meet validity criteria.

@Ninzero
Copy link
Author

Ninzero commented Oct 24, 2022

I see. Since PEP 426 only indicated which characters are allowed in package names. Maybe we should reject all package name with any invalid characters in it (by throwing an error)?

@neersighted
Copy link
Member

Closing as this is not mergable; a check for invalid characters in a pretty name (name = is a pretty name and not a canonicalized name) would likely be welcome, however.

Copy link

This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants