Skip to content

[python] Fix invalid pip syntax for httpx/tornado in requirements.txt#23889

Merged
wing328 merged 1 commit into
OpenAPITools:masterfrom
saturncloud:fix/python-requirements-httpx-tornado-syntax
May 28, 2026
Merged

[python] Fix invalid pip syntax for httpx/tornado in requirements.txt#23889
wing328 merged 1 commit into
OpenAPITools:masterfrom
saturncloud:fix/python-requirements-httpx-tornado-syntax

Conversation

@hhuuggoo

@hhuuggoo hhuuggoo commented May 28, 2026

Copy link
Copy Markdown
Contributor

Description of the PR

The httpx and tornado entries in the python generator's
requirements.mustache template were written using TOML / Pipfile-style
name = "spec" assignment syntax, which is not valid in a pip
requirements.txt file. The other entries in the same template
(urllib3, python_dateutil, pydantic, aiohttp, etc.) all use the
correct pip syntax — only these two lines are wrong.

As a result, every Python client generated with --library httpx
fails immediately at pip install -r requirements.txt:

ERROR: Invalid requirement: 'httpx = ">= 0.28.1"': Expected semicolon (after name with no version specifier) or end
    httpx = ">= 0.28.1"
          ^ (from line 2 of requirements.txt)

The same bug would affect --library tornado (same broken pattern on the
line below it in the template), though that path is less commonly used.

What this PR changes

In modules/openapi-generator/src/main/resources/python/requirements.mustache:

 {{#httpx}}
-httpx = ">= 0.28.1"
+httpx >= 0.28.1
 {{/httpx}}
 {{#tornado}}
-tornado = ">= 4.2, < 5"
+tornado >= 4.2, < 5
 {{/tornado}}

And the committed sample at
samples/openapi3/client/petstore/python-httpx/requirements.txt is
regenerated to match.

Scope check — was this bug anywhere else?

I checked the other two python dependency templates:

  • python/setup.mustachenot affected. The install_requires
    entries already use correct pip syntax: "httpx >= 0.28.1",
    "tornado>=4.2, < 5".
  • python/pyproject.mustachenot affected. Both dependency
    sections are syntactically valid:
    • [tool.poetry.dependencies] uses httpx = ">= 0.28.1", which is
      the correct TOML form for Poetry.
    • [project].dependencies uses "httpx (>=0.28.1)", which is the
      correct PEP 621 form.

So the fix is isolated to requirements.mustache plus its
corresponding sample.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work.
  • Run the shell script(s) under ./bin/ (or Windows batch scripts under .\bin\windows) to update Petstore samples related to your fix. (Only the python-httpx sample changed; updated in this PR.)
  • File the PR against the correct branch: master branch for non-breaking changes.
  • Copy the technical committee to review the pull request if your PR is targeting a particular programming language.

cc @OpenAPITools/generator-core-team
cc python technical committee


Summary by cubic

Fix pip requirement syntax for httpx and tornado in the Python generator so generated clients install cleanly. Replaces TOML-style name = "spec" with valid pip specifiers and updates the python-httpx sample.

  • Bug Fixes
    • In python/requirements.mustache, use httpx >= 0.28.1 and tornado >= 4.2, < 5.
    • Regenerated samples/openapi3/client/petstore/python-httpx/requirements.txt.
    • Verified setup.mustache and pyproject.mustache are already correct (no changes).

Written for commit f81d086. Summary will update on new commits.

Review in cubic

The httpx and tornado entries in the python generator's
requirements.mustache template were written using TOML/Pipfile-style
`name = "spec"` assignment syntax, which is invalid in a pip
requirements.txt file. The surrounding entries (urllib3,
python_dateutil, pydantic, etc.) all use the correct pip syntax.

This made `pip install -r requirements.txt` fail with:

    ERROR: Invalid requirement: 'httpx = ">= 0.28.1"': Expected
    semicolon (after name with no version specifier) or end
        httpx = ">= 0.28.1"
              ^ (from line 2 of requirements.txt)

for every Python client generated with `--library httpx` (and the same
issue would affect `--library tornado`).

The Poetry and PEP 621 sections of `pyproject.mustache` are unaffected;
they already use the correct syntax for their respective formats.

Also regenerated samples/openapi3/client/petstore/python-httpx/requirements.txt
to match the corrected template.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 2 files

Re-trigger cubic

@wing328

wing328 commented May 28, 2026

Copy link
Copy Markdown
Member

thanks for the fix

i'm able to repeat the issue with #23892

will add that after merging your fix.

@wing328 wing328 merged commit a49ea0f into OpenAPITools:master May 28, 2026
37 checks passed
@wing328 wing328 mentioned this pull request May 28, 2026
6 tasks
@wing328

wing328 commented May 28, 2026

Copy link
Copy Markdown
Member

FYI. Merged #23892 to update the CI workflow covering the issue moving forward.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants