Skip to content

Commit a0dd2bc

Browse files
committed
[python] Drop fallback for poetry 1.x
poetry 2.x is a year old now. We no longer need to keep this workaround. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent f56e9f1 commit a0dd2bc

8 files changed

Lines changed: 29 additions & 130 deletions

File tree

modules/openapi-generator/src/main/resources/python/pyproject.mustache

Lines changed: 1 addition & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,15 @@
1-
{{#poetry1}}
2-
[tool.poetry]
3-
{{/poetry1}}
4-
{{^poetry1}}
51
[project]
6-
{{/poetry1}}
72
name = "{{{packageName}}}"
83
version = "{{{packageVersion}}}"
94
description = "{{{appName}}}"
10-
{{#poetry1}}
11-
authors = ["{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}} <{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}>"]
12-
{{/poetry1}}
13-
{{^poetry1}}
145
authors = [
15-
{name = "{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}",email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}"},
6+
{name = "{{infoName}}{{^infoName}}OpenAPI Generator Community{{/infoName}}", email = "{{infoEmail}}{{^infoEmail}}team@openapitools.org{{/infoEmail}}"},
167
]
17-
{{/poetry1}}
188
{{#licenseInfo}}
19-
{{#poetry1}}
20-
license = "{{{licenseInfo}}}"
21-
{{/poetry1}}
22-
{{^poetry1}}
239
license = { text = "{{{licenseInfo}}}" }
24-
{{/poetry1}}
2510
{{/licenseInfo}}
2611
readme = "README.md"
27-
{{#poetry1}}
28-
repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}"
29-
{{/poetry1}}
3012
keywords = ["OpenAPI", "OpenAPI-Generator", "{{{appName}}}"]
31-
{{#poetry1}}
32-
include = ["{{packageName}}/py.typed"]
33-
34-
[tool.poetry.dependencies]
35-
python = "^3.9"
36-
{{^async}}
37-
urllib3 = ">= 2.1.0, < 3.0.0"
38-
{{/async}}
39-
python-dateutil = ">= 2.8.2"
40-
{{#asyncio}}
41-
aiohttp = ">= 3.8.4"
42-
aiohttp-retry = ">= 2.8.3"
43-
{{/asyncio}}
44-
{{#httpx}}
45-
httpx = ">= 0.28.1"
46-
{{/httpx}}
47-
{{#tornado}}
48-
tornado = ">=4.2, <5"
49-
{{/tornado}}
50-
{{#hasHttpSignatureMethods}}
51-
pem = ">= 19.3.0"
52-
pycryptodome = ">= 3.9.0"
53-
{{/hasHttpSignatureMethods}}
54-
pydantic = ">= 2"
55-
typing-extensions = ">= 4.7.1"
56-
{{#lazyImports}}
57-
lazy-imports = ">= 1, < 2"
58-
{{/lazyImports}}
59-
{{/poetry1}}
60-
{{^poetry1}}
6113
requires-python = ">=3.9"
6214

6315
dependencies = [
@@ -89,18 +41,10 @@ dependencies = [
8941
[project.urls]
9042
Repository = "https://{{{gitHost}}}/{{{gitUserId}}}/{{{gitRepoId}}}"
9143
92-
{{/poetry1}}
93-
{{^poetry1}}
9444
[tool.poetry]
9545
requires-poetry = ">=2.0"
96-
{{/poetry1}}
9746

98-
{{#poetry1}}
99-
[tool.poetry.dev-dependencies]
100-
{{/poetry1}}
101-
{{^poetry1}}
10247
[tool.poetry.group.dev.dependencies]
103-
{{/poetry1}}
10448
pytest = ">= 7.2.1"
10549
pytest-cov = ">= 2.8.1"
10650
tox = ">= 3.9.0"

modules/openapi-generator/src/test/java/org/openapitools/codegen/python/PythonClientCodegenTest.java

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -613,7 +613,7 @@ public void testInitFileImportsExports() throws IOException {
613613
assertFileContains(initFilePath, "from openapi_client.models.user import User as User");
614614
}
615615

616-
@Test(description = "Verify default license format uses object notation when poetry1 is false")
616+
@Test(description = "Verify default license format uses object notation")
617617
public void testLicenseFormatInPyprojectToml() throws IOException {
618618
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
619619
output.deleteOnExit();
@@ -633,56 +633,4 @@ public void testLicenseFormatInPyprojectToml() throws IOException {
633633
TestUtils.assertFileContains(Paths.get(output.getAbsolutePath(), "pyproject.toml"),
634634
"license = { text = \"MIT\" }");
635635
}
636-
637-
@Test(description = "Verify poetry1 mode uses string notation for license")
638-
public void testPoetry1LicenseFormat() throws IOException {
639-
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
640-
output.deleteOnExit();
641-
642-
final CodegenConfigurator configurator = new CodegenConfigurator()
643-
.setGeneratorName("python")
644-
.setInputSpec("src/test/resources/bugs/issue_21619.yaml")
645-
.setOutputDir(output.getAbsolutePath())
646-
.addAdditionalProperty("licenseInfo", "Apache-2.0")
647-
.addAdditionalProperty("poetry1", true); // Enable legacy poetry1 mode
648-
649-
DefaultGenerator generator = new DefaultGenerator();
650-
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
651-
files.forEach(File::deleteOnExit);
652-
653-
Path pyprojectPath = Paths.get(output.getAbsolutePath(), "pyproject.toml");
654-
TestUtils.assertFileExists(pyprojectPath);
655-
656-
// In poetry1 mode, license should use simple string format: "Apache-2.0"
657-
TestUtils.assertFileContains(pyprojectPath, "license = \"Apache-2.0\"");
658-
659-
// Verify it does NOT use the new object format
660-
TestUtils.assertFileNotContains(pyprojectPath, "license = { text = \"Apache-2.0\" }");
661-
}
662-
663-
@Test(description = "Verify non-poetry1 mode uses object notation for license")
664-
public void testNonPoetry1LicenseFormat() throws IOException {
665-
File output = Files.createTempDirectory("test").toFile().getCanonicalFile();
666-
output.deleteOnExit();
667-
668-
final CodegenConfigurator configurator = new CodegenConfigurator()
669-
.setGeneratorName("python")
670-
.setInputSpec("src/test/resources/bugs/issue_21619.yaml")
671-
.setOutputDir(output.getAbsolutePath())
672-
.addAdditionalProperty("licenseInfo", "BSD-3-Clause")
673-
.addAdditionalProperty("poetry1", false); // Explicitly disable poetry1 mode
674-
675-
DefaultGenerator generator = new DefaultGenerator();
676-
List<File> files = generator.opts(configurator.toClientOptInput()).generate();
677-
files.forEach(File::deleteOnExit);
678-
679-
Path pyprojectPath = Paths.get(output.getAbsolutePath(), "pyproject.toml");
680-
TestUtils.assertFileExists(pyprojectPath);
681-
682-
// In non-poetry1 mode, license should use object format: { text = "BSD-3-Clause" }
683-
TestUtils.assertFileContains(pyprojectPath, "license = { text = \"BSD-3-Clause\" }");
684-
685-
// Verify it does NOT use the legacy string format
686-
TestUtils.assertFileNotContains(pyprojectPath, "license = \"BSD-3-Clause\"");
687-
}
688636
}

samples/client/echo_api/python-disallowAdditionalPropertiesIfNotPresent/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "openapi_client"
33
version = "1.0.0"
44
description = "Echo Server API"
55
authors = [
6-
{name = "OpenAPI Generator Community",email = "team@openapitools.org"},
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
77
]
88
license = { text = "Apache 2.0" }
99
readme = "README.md"

samples/client/echo_api/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "openapi_client"
33
version = "1.0.0"
44
description = "Echo Server API"
55
authors = [
6-
{name = "OpenAPI Generator Community",email = "team@openapitools.org"},
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
77
]
88
license = { text = "Apache 2.0" }
99
readme = "README.md"

samples/openapi3/client/petstore/python-aiohttp/pyproject.toml

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,32 @@
1-
[tool.poetry]
1+
[project]
22
name = "petstore_api"
33
version = "1.0.0"
44
description = "OpenAPI Petstore"
5-
authors = ["OpenAPI Generator Community <team@openapitools.org>"]
6-
license = "Apache-2.0"
5+
authors = [
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
7+
]
8+
license = { text = "Apache-2.0" }
79
readme = "README.md"
8-
repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
910
keywords = ["OpenAPI", "OpenAPI-Generator", "OpenAPI Petstore"]
10-
include = ["petstore_api/py.typed"]
11+
requires-python = ">=3.9"
12+
13+
dependencies = [
14+
"python-dateutil (>=2.8.2)",
15+
"aiohttp (>=3.8.4)",
16+
"aiohttp-retry (>=2.8.3)",
17+
"pem (>=19.3.0)",
18+
"pycryptodome (>=3.9.0)",
19+
"pydantic (>=2)",
20+
"typing-extensions (>=4.7.1)",
21+
]
22+
23+
[project.urls]
24+
Repository = "https://github.com/GIT_USER_ID/GIT_REPO_ID"
1125

12-
[tool.poetry.dependencies]
13-
python = "^3.9"
14-
python-dateutil = ">= 2.8.2"
15-
aiohttp = ">= 3.8.4"
16-
aiohttp-retry = ">= 2.8.3"
17-
pem = ">= 19.3.0"
18-
pycryptodome = ">= 3.9.0"
19-
pydantic = ">= 2"
20-
typing-extensions = ">= 4.7.1"
26+
[tool.poetry]
27+
requires-poetry = ">=2.0"
2128

22-
[tool.poetry.dev-dependencies]
29+
[tool.poetry.group.dev.dependencies]
2330
pytest = ">= 7.2.1"
2431
pytest-cov = ">= 2.8.1"
2532
tox = ">= 3.9.0"

samples/openapi3/client/petstore/python-httpx/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "petstore_api"
33
version = "1.0.0"
44
description = "OpenAPI Petstore"
55
authors = [
6-
{name = "OpenAPI Generator Community",email = "team@openapitools.org"},
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
77
]
88
license = { text = "Apache-2.0" }
99
readme = "README.md"

samples/openapi3/client/petstore/python-lazyImports/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "petstore_api"
33
version = "1.0.0"
44
description = "OpenAPI Petstore"
55
authors = [
6-
{name = "OpenAPI Generator Community",email = "team@openapitools.org"},
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
77
]
88
license = { text = "Apache-2.0" }
99
readme = "README.md"

samples/openapi3/client/petstore/python/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name = "petstore_api"
33
version = "1.0.0"
44
description = "OpenAPI Petstore"
55
authors = [
6-
{name = "OpenAPI Generator Community",email = "team@openapitools.org"},
6+
{name = "OpenAPI Generator Community", email = "team@openapitools.org"},
77
]
88
license = { text = "Apache-2.0" }
99
readme = "README.md"

0 commit comments

Comments
 (0)