Skip to content

Prevent poetry from creating projects with invalid project names #10170

@Ronimsenn

Description

@Ronimsenn

Issue Kind

Change in current behaviour

Description

Using Poetry 2.0.1 on Windows 11.

When creating a poetry project with a + in the project name - might be the same for other invalid characters -, generation runs smoothly:

D:\Development\test> poetry init -v

This command will guide you through creating your pyproject.toml config.

Package name [test]:  test+test
Version [0.1.0]:
Description []:
Author [Your Name <[email protected]>, n to skip]:  n
License []:
Trying to detect current active python executable as specified in the config.
Found: D:\Program Files\Python313\python.EXE
Compatible Python versions [>=3.13]:

Would you like to define your main dependencies interactively? (yes/no) [yes] no
Would you like to define your development dependencies interactively? (yes/no) [yes] no
Generated file

[project]
name = "test+test"
version = "0.1.0"
description = ""
authors = [
    {name = "Your Name",email = "[email protected]"}
]
readme = "README.md"
requires-python = ">=3.13"
dependencies = [
]

[build-system]
requires = ["poetry-core>=2.0.0,<3.0.0"]
build-backend = "poetry.core.masonry.api"

Do you confirm generation? (yes/no) [yes] yes

Then, when trying to add a new dependency with poetry add, it fails due to an invalid project name:

D:\Development\test> poetry add requests

The Poetry configuration is invalid:
  - project.name must match pattern ^([a-zA-Z\d]|[a-zA-Z\d][\w.-]*[a-zA-Z\d])$

Impact

Prevent the user from creating projects with invalid names.
While the current behaviour is not in any way problematic or breaking, it's unexpected and should be improved in my opinion.

Workarounds

Use a project name with no + :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    kind/featureFeature requests/implementationsstatus/triageThis issue needs to be triaged

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions