Skip to content

Turn spaces in project name to underscore.#6085

Closed
Ninzero wants to merge 1 commit into
python-poetry:masterfrom
Ninzero:space-to-underscore
Closed

Turn spaces in project name to underscore.#6085
Ninzero wants to merge 1 commit into
python-poetry:masterfrom
Ninzero:space-to-underscore

Conversation

@Ninzero
Copy link
Copy Markdown

@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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

@github-actions
Copy link
Copy Markdown

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