From 03781d3a9392aecbceba95591d5874f9a74bb3a6 Mon Sep 17 00:00:00 2001 From: Jonathan Ballet Date: Sun, 1 Oct 2023 15:22:42 +0200 Subject: [PATCH] python: remove aenum in favor of stdlib's enum (#16691) The aenum dependency didn't provide any specific improvements over the stdlib's enum module. aenum also doesn't provide typing information at the moment. This removes one dependency and will help for completing the typing of the generated client. --- .../src/main/resources/python/README_onlypackage.mustache | 1 - .../src/main/resources/python/model_enum.mustache | 3 ++- .../src/main/resources/python/pyproject.mustache | 1 - .../src/main/resources/python/requirements.mustache | 1 - .../openapi-generator/src/main/resources/python/setup.mustache | 1 - .../echo_api/python/openapi_client/models/string_enum_ref.py | 3 ++- samples/client/echo_api/python/pyproject.toml | 1 - samples/client/echo_api/python/requirements.txt | 1 - samples/client/echo_api/python/setup.py | 1 - .../petstore/python-aiohttp/petstore_api/models/enum_class.py | 3 ++- .../python-aiohttp/petstore_api/models/enum_string1.py | 3 ++- .../python-aiohttp/petstore_api/models/enum_string2.py | 3 ++- .../petstore/python-aiohttp/petstore_api/models/outer_enum.py | 3 ++- .../petstore_api/models/outer_enum_default_value.py | 3 ++- .../python-aiohttp/petstore_api/models/outer_enum_integer.py | 3 ++- .../petstore_api/models/outer_enum_integer_default_value.py | 3 ++- .../python-aiohttp/petstore_api/models/single_ref_type.py | 3 ++- .../petstore_api/models/special_character_enum.py | 3 ++- samples/openapi3/client/petstore/python-aiohttp/pyproject.toml | 1 - .../openapi3/client/petstore/python-aiohttp/requirements.txt | 1 - samples/openapi3/client/petstore/python-aiohttp/setup.py | 1 - .../client/petstore/python/petstore_api/models/enum_class.py | 3 ++- .../client/petstore/python/petstore_api/models/enum_string1.py | 3 ++- .../client/petstore/python/petstore_api/models/enum_string2.py | 3 ++- .../client/petstore/python/petstore_api/models/outer_enum.py | 3 ++- .../python/petstore_api/models/outer_enum_default_value.py | 3 ++- .../petstore/python/petstore_api/models/outer_enum_integer.py | 3 ++- .../petstore_api/models/outer_enum_integer_default_value.py | 3 ++- .../petstore/python/petstore_api/models/single_ref_type.py | 3 ++- .../python/petstore_api/models/special_character_enum.py | 3 ++- samples/openapi3/client/petstore/python/pyproject.toml | 1 - samples/openapi3/client/petstore/python/requirements.txt | 1 - samples/openapi3/client/petstore/python/setup.py | 1 - 33 files changed, 40 insertions(+), 33 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/python/README_onlypackage.mustache b/modules/openapi-generator/src/main/resources/python/README_onlypackage.mustache index d04bc051f1d..7195605a069 100644 --- a/modules/openapi-generator/src/main/resources/python/README_onlypackage.mustache +++ b/modules/openapi-generator/src/main/resources/python/README_onlypackage.mustache @@ -34,7 +34,6 @@ To be able to use it, you will need these dependencies in your own package that * tornado>=4.2,<5 {{/tornado}} * pydantic -* aenum ## Getting Started diff --git a/modules/openapi-generator/src/main/resources/python/model_enum.mustache b/modules/openapi-generator/src/main/resources/python/model_enum.mustache index 83f0552c781..8a59dd5bc7e 100644 --- a/modules/openapi-generator/src/main/resources/python/model_enum.mustache +++ b/modules/openapi-generator/src/main/resources/python/model_enum.mustache @@ -1,7 +1,8 @@ +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum {{#vendorExtensions.x-py-datetime-imports}}{{#-first}}from datetime import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-datetime-imports}} {{#vendorExtensions.x-py-typing-imports}}{{#-first}}from typing import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-typing-imports}} {{#vendorExtensions.x-py-pydantic-imports}}{{#-first}}from pydantic import{{/-first}} {{{.}}}{{^-last}},{{/-last}}{{/vendorExtensions.x-py-pydantic-imports}} diff --git a/modules/openapi-generator/src/main/resources/python/pyproject.mustache b/modules/openapi-generator/src/main/resources/python/pyproject.mustache index 3b0a95c5bd6..568fa4ebf94 100644 --- a/modules/openapi-generator/src/main/resources/python/pyproject.mustache +++ b/modules/openapi-generator/src/main/resources/python/pyproject.mustache @@ -25,7 +25,6 @@ pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" {{/hasHttpSignatureMethods}} pydantic = ">=2" -aenum = ">=3.1.11" typing-extensions = ">=4.7.1" [tool.poetry.dev-dependencies] diff --git a/modules/openapi-generator/src/main/resources/python/requirements.mustache b/modules/openapi-generator/src/main/resources/python/requirements.mustache index 152a124fd34..0fa8f6fd14d 100644 --- a/modules/openapi-generator/src/main/resources/python/requirements.mustache +++ b/modules/openapi-generator/src/main/resources/python/requirements.mustache @@ -2,7 +2,6 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 pydantic >= 2 -aenum >= 3.1.11 typing-extensions >= 4.7.1 {{#asyncio}} aiohttp >= 3.0.0 diff --git a/modules/openapi-generator/src/main/resources/python/setup.mustache b/modules/openapi-generator/src/main/resources/python/setup.mustache index e539bb1c487..1468f827370 100644 --- a/modules/openapi-generator/src/main/resources/python/setup.mustache +++ b/modules/openapi-generator/src/main/resources/python/setup.mustache @@ -30,7 +30,6 @@ REQUIRES = [ "pycryptodome>=3.9.0", {{/hasHttpSignatureMethods}} "pydantic >= 2", - "aenum", "typing-extensions >= 4.7.1", ] diff --git a/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py b/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py index f200a1dafb8..18bef6e7efa 100644 --- a/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py +++ b/samples/client/echo_api/python/openapi_client/models/string_enum_ref.py @@ -13,10 +13,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/client/echo_api/python/pyproject.toml b/samples/client/echo_api/python/pyproject.toml index c79828a122d..af471ab6314 100644 --- a/samples/client/echo_api/python/pyproject.toml +++ b/samples/client/echo_api/python/pyproject.toml @@ -15,7 +15,6 @@ python = "^3.7" urllib3 = ">= 1.25.3" python-dateutil = ">=2.8.2" pydantic = ">=2" -aenum = ">=3.1.11" typing-extensions = ">=4.7.1" [tool.poetry.dev-dependencies] diff --git a/samples/client/echo_api/python/requirements.txt b/samples/client/echo_api/python/requirements.txt index 4407c81fb74..cc85509ec51 100644 --- a/samples/client/echo_api/python/requirements.txt +++ b/samples/client/echo_api/python/requirements.txt @@ -2,5 +2,4 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 pydantic >= 2 -aenum >= 3.1.11 typing-extensions >= 4.7.1 diff --git a/samples/client/echo_api/python/setup.py b/samples/client/echo_api/python/setup.py index 54a88267fb4..82528555eef 100644 --- a/samples/client/echo_api/python/setup.py +++ b/samples/client/echo_api/python/setup.py @@ -28,7 +28,6 @@ REQUIRES = [ "urllib3 >= 1.25.3, < 2.1.0", "python-dateutil", "pydantic >= 2", - "aenum", "typing-extensions >= 4.7.1", ] diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py index f3037885ed6..b7d443776de 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_class.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py index 8ced7d15629..71f9f0c10c1 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string1.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py index 1ee33810910..2cba894b5d7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/enum_string2.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py index bfb06a008b5..eaed7b60214 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py index 807c36f0fe5..6d3bc533869 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_default_value.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py index 77ae46fa705..0c885e23b9c 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py index 36381197bb7..99ca40483d6 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/outer_enum_integer_default_value.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py index 7edec4bb32c..bc190318849 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/single_ref_type.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py index 14b8a7e3fd6..0443972f8d7 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py +++ b/samples/openapi3/client/petstore/python-aiohttp/petstore_api/models/special_character_enum.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml b/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml index a55f8d02258..6747ce2b913 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml +++ b/samples/openapi3/client/petstore/python-aiohttp/pyproject.toml @@ -18,7 +18,6 @@ aiohttp = ">= 3.8.4" pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" pydantic = ">=2" -aenum = ">=3.1.11" typing-extensions = ">=4.7.1" [tool.poetry.dev-dependencies] diff --git a/samples/openapi3/client/petstore/python-aiohttp/requirements.txt b/samples/openapi3/client/petstore/python-aiohttp/requirements.txt index 01b8ae0800c..870cfc37f34 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/requirements.txt +++ b/samples/openapi3/client/petstore/python-aiohttp/requirements.txt @@ -2,7 +2,6 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 pydantic >= 2 -aenum >= 3.1.11 typing-extensions >= 4.7.1 aiohttp >= 3.0.0 pycryptodome >= 3.9.0 diff --git a/samples/openapi3/client/petstore/python-aiohttp/setup.py b/samples/openapi3/client/petstore/python-aiohttp/setup.py index b32a4ab0454..4c8c7663615 100644 --- a/samples/openapi3/client/petstore/python-aiohttp/setup.py +++ b/samples/openapi3/client/petstore/python-aiohttp/setup.py @@ -30,7 +30,6 @@ REQUIRES = [ "pem>=19.3.0", "pycryptodome>=3.9.0", "pydantic >= 2", - "aenum", "typing-extensions >= 4.7.1", ] diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py index f3037885ed6..b7d443776de 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_class.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py index 8ced7d15629..71f9f0c10c1 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string1.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py index 1ee33810910..2cba894b5d7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/enum_string2.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py index bfb06a008b5..eaed7b60214 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py index 807c36f0fe5..6d3bc533869 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_default_value.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py index 77ae46fa705..0c885e23b9c 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py index 36381197bb7..99ca40483d6 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/outer_enum_integer_default_value.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py b/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py index 7edec4bb32c..bc190318849 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/single_ref_type.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py b/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py index 14b8a7e3fd6..0443972f8d7 100644 --- a/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py +++ b/samples/openapi3/client/petstore/python/petstore_api/models/special_character_enum.py @@ -12,10 +12,11 @@ """ # noqa: E501 +from __future__ import annotations import json import pprint import re # noqa: F401 -from aenum import Enum, no_arg +from enum import Enum diff --git a/samples/openapi3/client/petstore/python/pyproject.toml b/samples/openapi3/client/petstore/python/pyproject.toml index 8474b70954d..0d153fcb0c3 100644 --- a/samples/openapi3/client/petstore/python/pyproject.toml +++ b/samples/openapi3/client/petstore/python/pyproject.toml @@ -17,7 +17,6 @@ python-dateutil = ">=2.8.2" pem = ">= 19.3.0" pycryptodome = ">= 3.9.0" pydantic = ">=2" -aenum = ">=3.1.11" typing-extensions = ">=4.7.1" [tool.poetry.dev-dependencies] diff --git a/samples/openapi3/client/petstore/python/requirements.txt b/samples/openapi3/client/petstore/python/requirements.txt index 111e2d917cb..f74f344f853 100755 --- a/samples/openapi3/client/petstore/python/requirements.txt +++ b/samples/openapi3/client/petstore/python/requirements.txt @@ -2,6 +2,5 @@ python_dateutil >= 2.5.3 setuptools >= 21.0.0 urllib3 >= 1.25.3, < 2.1.0 pydantic >= 2 -aenum >= 3.1.11 typing-extensions >= 4.7.1 pycryptodome >= 3.9.0 diff --git a/samples/openapi3/client/petstore/python/setup.py b/samples/openapi3/client/petstore/python/setup.py index 758e24ebd86..ae616afcb1b 100755 --- a/samples/openapi3/client/petstore/python/setup.py +++ b/samples/openapi3/client/petstore/python/setup.py @@ -29,7 +29,6 @@ REQUIRES = [ "pem>=19.3.0", "pycryptodome>=3.9.0", "pydantic >= 2", - "aenum", "typing-extensions >= 4.7.1", ]