Skip to content

[python] Fix poetry deprecation warnings #21268

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
May 25, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/generators/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ These options may be applied as additional-properties (cli) or configOptions (pl
|packageName|python package name (convention: snake_case).| |openapi_client|
|packageUrl|python package URL.| |null|
|packageVersion|python package version.| |1.0.0|
|poetry1|Fallback to formatting pyproject.toml to Poetry 1.x format.| |null|
|projectName|python project name in setup.py (e.g. petstore-api).| |null|
|recursionLimit|Set the recursion limit. If not set, use the system default value.| |null|
|setEnsureAsciiToFalse|When set to true, add `ensure_ascii=False` in json.dumps when creating the HTTP request body.| |false|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public class PythonClientCodegen extends AbstractPythonCodegen implements Codege
public static final String DATETIME_FORMAT = "datetimeFormat";
public static final String DATE_FORMAT = "dateFormat";
public static final String SET_ENSURE_ASCII_TO_FALSE = "setEnsureAsciiToFalse";
public static final String POETRY1_FALLBACK = "poetry1";

@Setter protected String packageUrl;
protected String apiDocPath = "docs/";
Expand Down Expand Up @@ -149,6 +150,7 @@ public PythonClientCodegen() {
cliOptions.add(new CliOption(DATE_FORMAT, "date format for query parameters")
.defaultValue("%Y-%m-%d"));
cliOptions.add(new CliOption(CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP, CodegenConstants.USE_ONEOF_DISCRIMINATOR_LOOKUP_DESC).defaultValue("false"));
cliOptions.add(new CliOption(POETRY1_FALLBACK, "Fallback to formatting pyproject.toml to Poetry 1.x format."));

supportedLibraries.put("urllib3", "urllib3-based client");
supportedLibraries.put("asyncio", "asyncio-based client");
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
{{#poetry1}}
[tool.poetry]
{{/poetry1}}
{{^poetry1}}
[project]
{{/poetry1}}
name = "{{{packageName}}}"
version = "{{{packageVersion}}}"
description = "{{{appName}}}"
{{#poetry1}}
authors = ["{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}[email protected]{{/infoEmail}}>"]
{{/poetry1}}
{{^poetry1}}
authors = [
{name = "{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}",email = "{{infoEmail}}{{^infoEmail}}[email protected]{{/infoEmail}}"},
]
{{/poetry1}}
license = "{{{licenseInfo}}}{{^licenseInfo}}NoLicense{{/licenseInfo}}"
readme = "README.md"
{{#poetry1}}
repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}"
{{/poetry1}}
keywords = ["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"]
{{#poetry1}}
include = ["{{packageName}}/py.typed"]

[tool.poetry.dependencies]
python = "^3.9"

urllib3 = ">= 2.1.0, < 3.0.0"
python-dateutil = ">= 2.8.2"
{{#asyncio}}
Expand All @@ -27,8 +41,43 @@ pycryptodome = ">= 3.9.0"
{{/hasHttpSignatureMethods}}
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"
{{/poetry1}}
{{^poetry1}}
requires-python = "^3.9"

dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
{{#asyncio}}
"aiohttp (>=3.8.4)",
"aiohttp-retry (>=2.8.3)",
{{/asyncio}}
{{#tornado}}
"tornado (>=4.2,<5)",
{{/tornado}}
{{#hasHttpSignatureMethods}}
"pem (>=19.3.0)",
"pycryptodome (>=3.9.0)",
{{/hasHttpSignatureMethods}}
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

[project.urls]
Repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}"

{{/poetry1}}
{{^poetry1}}
[tool.poetry]
requires-poetry = ">=2.0"
{{/poetry1}}

{{#poetry1}}
[tool.poetry.dev-dependencies]
{{/poetry1}}
{{^poetry1}}
[tool.poetry.group.dev.dependencies]
{{/poetry1}}
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
[tool.poetry]
[project]
name = "openapi_client"
version = "1.0.0"
description = "Echo Server API"
authors = ["OpenAPI Generator Community <[email protected]>"]
authors = [
{name = "OpenAPI Generator Community",email = "[email protected]"},
]
license = "Apache 2.0"
readme = "README.md"
repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
keywords = ["OpenAPI", "OpenAPI-Generator", "Echo Server API"]
include = ["openapi_client/py.typed"]
requires-python = "^3.9"

[tool.poetry.dependencies]
python = "^3.9"
dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

urllib3 = ">= 2.1.0, < 3.0.0"
python-dateutil = ">= 2.8.2"
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"
[project.urls]
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"

[tool.poetry]
requires-poetry = ">=2.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
Expand Down
28 changes: 17 additions & 11 deletions samples/client/echo_api/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,23 +1,29 @@
[tool.poetry]
[project]
name = "openapi_client"
version = "1.0.0"
description = "Echo Server API"
authors = ["OpenAPI Generator Community <[email protected]>"]
authors = [
{name = "OpenAPI Generator Community",email = "[email protected]"},
]
license = "Apache 2.0"
readme = "README.md"
repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
keywords = ["OpenAPI", "OpenAPI-Generator", "Echo Server API"]
include = ["openapi_client/py.typed"]
requires-python = "^3.9"

[tool.poetry.dependencies]
python = "^3.9"
dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

urllib3 = ">= 2.1.0, < 3.0.0"
python-dateutil = ">= 2.8.2"
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"
[project.urls]
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"

[tool.poetry]
requires-poetry = ">=2.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
Expand Down
36 changes: 21 additions & 15 deletions samples/openapi3/client/petstore/python-aiohttp/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,27 +1,33 @@
[tool.poetry]
[project]
name = "petstore_api"
version = "1.0.0"
description = "OpenAPI Petstore"
authors = ["OpenAPI Generator Community <[email protected]>"]
authors = [
{name = "OpenAPI Generator Community",email = "[email protected]"},
]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
keywords = ["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"]
include = ["petstore_api/py.typed"]
requires-python = "^3.9"

[tool.poetry.dependencies]
python = "^3.9"
dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
"aiohttp (>=3.8.4)",
"aiohttp-retry (>=2.8.3)",
"pem (>=19.3.0)",
"pycryptodome (>=3.9.0)",
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

urllib3 = ">= 2.1.0, < 3.0.0"
python-dateutil = ">= 2.8.2"
aiohttp = ">= 3.8.4"
aiohttp-retry = ">= 2.8.3"
pem = ">= 19.3.0"
pycryptodome = ">= 3.9.0"
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"
[project.urls]
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"

[tool.poetry]
requires-poetry = ">=2.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
Expand Down
32 changes: 19 additions & 13 deletions samples/openapi3/client/petstore/python/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
[tool.poetry]
[project]
name = "petstore_api"
version = "1.0.0"
description = "OpenAPI Petstore"
authors = ["OpenAPI Generator Community <[email protected]>"]
authors = [
{name = "OpenAPI Generator Community",email = "[email protected]"},
]
license = "Apache-2.0"
readme = "README.md"
repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
keywords = ["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"]
include = ["petstore_api/py.typed"]
requires-python = "^3.9"

[tool.poetry.dependencies]
python = "^3.9"
dependencies = [
"urllib3 (>=2.1.0,<3.0.0)",
"python-dateutil (>=2.8.2)",
"pem (>=19.3.0)",
"pycryptodome (>=3.9.0)",
"pydantic (>=2)",
"typing-extensions (>=4.7.1)"
]

urllib3 = ">= 2.1.0, < 3.0.0"
python-dateutil = ">= 2.8.2"
pem = ">= 19.3.0"
pycryptodome = ">= 3.9.0"
pydantic = ">= 2"
typing-extensions = ">= 4.7.1"
[project.urls]
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"

[tool.poetry]
requires-poetry = ">=2.0"

[tool.poetry.dev-dependencies]
[tool.poetry.group.dev.dependencies]
pytest = ">= 7.2.1"
pytest-cov = ">= 2.8.1"
tox = ">= 3.9.0"
Expand Down
Loading