python: simplify module imports (#17507)

In #16624, I introduced a new mechanism to record imports to other
modules, instead of having specialized datetime/typing/pydantic objects
to manage imports for these modules.

This change reuses the mechanism from #16624 and replace the specialized
import managers by the generic one. Unused imports from various
.mustache templates are also cleaned up.
This commit is contained in:
Jonathan Ballet
2024-01-03 14:22:53 +01:00
committed by GitHub
parent dffb5c121f
commit 063865973d
266 changed files with 356 additions and 1335 deletions

View File

@@ -12,12 +12,9 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated

View File

@@ -12,24 +12,18 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated
except ImportError:
from typing_extensions import Annotated
from pydantic import Field
from typing_extensions import Annotated
from pydantic import StrictBytes, StrictStr
from pydantic import Field, StrictBytes, StrictStr
from typing import Any, Dict, List, Optional, Union
from typing_extensions import Annotated
from openapi_client.models.pet import Pet
from openapi_client.models.tag import Tag
@@ -519,7 +513,7 @@ class BodyApi:
if body is not None:
# convert to byte array if the input is a file name (str)
if isinstance(body, str):
with io.open(body, "rb") as _fp:
with open(body, "rb") as _fp:
_body_params = _fp.read()
else:
_body_params = body

View File

@@ -12,12 +12,9 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated
@@ -25,10 +22,8 @@ except ImportError:
from typing_extensions import Annotated
from pydantic import StrictBool, StrictInt, StrictStr
from typing import Optional
from openapi_client.api_client import ApiClient
from openapi_client.api_response import ApiResponse
from openapi_client.rest import RESTResponseType

View File

@@ -12,12 +12,9 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated
@@ -25,9 +22,7 @@ except ImportError:
from typing_extensions import Annotated
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
from typing import Optional
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.api_client import ApiClient

View File

@@ -12,12 +12,9 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated
@@ -25,7 +22,6 @@ except ImportError:
from typing_extensions import Annotated
from pydantic import StrictInt, StrictStr, field_validator
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.api_client import ApiClient

View File

@@ -12,12 +12,9 @@
Do not edit the class manually.
""" # noqa: E501
import io
import warnings
from pydantic import validate_call, Field, StrictFloat, StrictStr, StrictInt
from typing import Dict, List, Optional, Tuple, Union, Any
from typing import Any, Dict, List, Optional, Tuple, Union
try:
from typing import Annotated
@@ -25,11 +22,8 @@ except ImportError:
from typing_extensions import Annotated
from datetime import date, datetime
from pydantic import StrictBool, StrictInt, StrictStr, field_validator
from typing import Any, Optional
from openapi_client.models.pet import Pet
from openapi_client.models.string_enum_ref import StringEnumRef
from openapi_client.models.test_query_style_form_explode_true_array_string_query_object_parameter import TestQueryStyleFormExplodeTrueArrayStringQueryObjectParameter