From 4e601fd073ad334f7db7df49feee110a03aaa75c Mon Sep 17 00:00:00 2001 From: iscai-msft Date: Fri, 5 Jun 2020 15:05:22 -0400 Subject: [PATCH] import models in operation group if there are just enums --- autorest/codegen/serializers/operation_group_serializer.py | 5 ++++- .../aio/operations_async/_float_operations_async.py | 2 ++ .../aio/operations_async/_int_operations_async.py | 2 ++ .../nonstringenums/operations/_float_operations.py | 2 ++ .../nonstringenums/operations/_int_operations.py | 2 ++ 5 files changed, 12 insertions(+), 1 deletion(-) diff --git a/autorest/codegen/serializers/operation_group_serializer.py b/autorest/codegen/serializers/operation_group_serializer.py index dcc34b94d94..ba073a0043d 100644 --- a/autorest/codegen/serializers/operation_group_serializer.py +++ b/autorest/codegen/serializers/operation_group_serializer.py @@ -33,7 +33,10 @@ def _is_paging(operation): code_model=self.code_model, operation_group=self.operation_group, imports=FileImportSerializer( - self.operation_group.imports(self.async_mode, bool(self.code_model.schemas)), + self.operation_group.imports( + self.async_mode, + bool(self.code_model.schemas or self.code_model.enums) + ), is_python_3_file=self.async_mode ), async_mode=self.async_mode, diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_float_operations_async.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_float_operations_async.py index 23a5eb39bfe..aafb8bbeb02 100644 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_float_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_float_operations_async.py @@ -13,6 +13,8 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ... import models + T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_int_operations_async.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_int_operations_async.py index 2ba9e06e414..0a1ed5235c1 100644 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_int_operations_async.py +++ b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/aio/operations_async/_int_operations_async.py @@ -13,6 +13,8 @@ from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.core.tracing.decorator_async import distributed_trace_async +from ... import models + T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py index 5332a7e1b3f..2335a9cdd63 100644 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_float_operations.py @@ -13,6 +13,8 @@ from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace +from .. import models + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union diff --git a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py index 9266e763c43..b5ca4e19102 100644 --- a/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py +++ b/test/vanilla/Expected/AcceptanceTests/NonStringEnums/nonstringenums/operations/_int_operations.py @@ -13,6 +13,8 @@ from azure.core.pipeline.transport import HttpRequest, HttpResponse from azure.core.tracing.decorator import distributed_trace +from .. import models + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union