Skip to content

Incorrect reformatting for complex version specifiers #112

@acdha

Description

@acdha

If I run a command like poetry add fastapi@latest it will generate a specifier like fastapi (>=0.121.2,<0.122.0).

Unfortunately, with the pyproject-fmt hook v2.11.1, that will be broken by removing the closing parentheses:

pyproject-fmt............................................................Failed
- hook id: pyproject-fmt
- exit code: 1
- files were modified by this hook

--- pyproject.toml

+++ pyproject.toml

@@ -22,7 +22,7 @@

 dependencies = [
   "anyio~=3.0",
   "internal-package~=1.19.2",
-  "fastapi (>=0.121.2,<0.122.0)",
+  "fastapi (>=0.121.2,<0.122",
   "httptools>=0.6.4,<0.7",
   "httpx>=0.28.1,<0.29",
   "pymysql>=1.1.1,<2",

Validate pyproject.toml..................................................Failed
- hook id: validate-pyproject
- exit code: 1

Invalid file: pyproject.toml
[ERROR] `project.dependencies[2]` must be pep508

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions