python-poetry / python-poetry/poetry

Prevent poetry from creating projects with invalid project names

Open
#10,170 12 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

kind/feature status/triage
Dominant language
Python
Stars
34.3k
Forks
2.5k
Avg merge
2d 19h
Merged PRs (30d)
30

Description

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 <you@example.com>, 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 = "you@example.com"}
]
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 + :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the flow with poetry init using a project name such as test+test, then run poetry add requests to observe the later validation failure. Change the project-creation path so invalid names are rejected before generation, and verify that valid names still generate a usable project.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
cli, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.