Skip to content
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Fix response type of paging operations from `Iterable` to `ItemPaged`
2 changes: 1 addition & 1 deletion packages/autorest.python/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
},
"homepage": "https://github.com/Azure/autorest.python/blob/main/README.md",
"dependencies": {
"@typespec/http-client-python": "~0.11.3",
"@typespec/http-client-python": "~0.12.0-dev.3",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "~4.19.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload
from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload

from my.library import CustomDefaultPollingMethod, CustomPager, CustomPoller

Expand All @@ -22,6 +22,7 @@
StreamConsumedError,
map_error,
)
from azure.core.paging import ItemPaged
from azure.core.pipeline import PipelineResponse
from azure.core.polling import NoPolling, PollingMethod
from azure.core.rest import HttpRequest, HttpResponse
Expand Down Expand Up @@ -274,7 +275,7 @@ def get_long_running_output(pipeline_response):
return CustomPoller[JSON](self._client, raw_result, get_long_running_output, polling_method) # type: ignore

@distributed_trace
def basic_paging(self, **kwargs: Any) -> Iterable[JSON]:
def basic_paging(self, **kwargs: Any) -> ItemPaged[JSON]:
"""A simple paging operation.

:return: An iterator like instance of JSON object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload

from my.library.aio import AsyncCustomDefaultPollingMethod, AsyncCustomPager, AsyncCustomPoller

from azure.core import AsyncPipelineClient
from azure.core.async_paging import AsyncList
from azure.core.async_paging import AsyncItemPaged, AsyncList
from azure.core.exceptions import (
ClientAuthenticationError,
HttpResponseError,
Expand Down Expand Up @@ -250,7 +250,7 @@ def get_long_running_output(pipeline_response):
)

@distributed_trace
def basic_paging(self, **kwargs: Any) -> AsyncIterable[JSON]:
def basic_paging(self, **kwargs: Any) -> AsyncItemPaged[JSON]:
"""A simple paging operation.

:return: An iterator like instance of JSON object
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# --------------------------------------------------------------------------
from ._utils.serialization import Serializer, Deserializer
from io import IOBase
from typing import Any, IO, Iterable, Iterator, Optional, Union
from typing import Any, IO, Iterator, Optional, Union

from azure.core.paging import ItemPaged
from azure.core.polling import LROPoller
Expand Down Expand Up @@ -53,7 +53,7 @@ def begin_test_lro_and_paging(
client_request_id: Optional[str] = None,
test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,
**kwargs: Any
) -> LROPoller[Iterable["_models.Product"]]:
) -> LROPoller[ItemPaged["_models.Product"]]:
"""A long-running paging operation that includes a nextLink that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -152,7 +152,7 @@ def test_one( # pylint: disable=inconsistent-return-statements
def test_paging(
self,
**kwargs: Any
) -> Iterable["_models.ModelThree"]:
) -> ItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
# --------------------------------------------------------------------------
from .._utils.serialization import Serializer, Deserializer
from io import IOBase
from typing import Any, AsyncIterable, AsyncIterator, IO, Optional, Union
from typing import Any, AsyncIterator, IO, Optional, Union

from azure.core.async_paging import AsyncItemPaged
from azure.core.polling import AsyncLROPoller
Expand Down Expand Up @@ -54,7 +54,7 @@ async def begin_test_lro_and_paging(
client_request_id: Optional[str] = None,
test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,
**kwargs: Any
) -> AsyncLROPoller[AsyncIterable["_models.Product"]]:
) -> AsyncLROPoller[AsyncItemPaged["_models.Product"]]:
"""A long-running paging operation that includes a nextLink that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -153,7 +153,7 @@ async def test_one(
def test_paging(
self,
**kwargs: Any
) -> AsyncIterable["_models.ModelThree"]:
) -> AsyncItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,8 @@
"operation_group_one": "OperationGroupOneOperations"
},
"operation_mixins": {
"sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}}, \"regular\": {\"stdlib\": {\"typing\": [\"IO\", \"Iterator\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}, \"sdkcore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"local\": {\".\": [[\"models\", \"_models\"]]}}}",
"async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}}, \"regular\": {\"stdlib\": {\"typing\": [\"AsyncIterator\", \"IO\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}, \"sdkcore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}, \"local\": {\"..\": [[\"models\", \"_models\"]]}}}",
"sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}, \"sdkcore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"stdlib\": {\"typing\": [\"IO\", \"Iterator\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}, \"sdkcore\": {\"azure.core.polling\": [\"LROPoller\"], \"azure.core.paging\": [\"ItemPaged\"]}, \"local\": {\".\": [[\"models\", \"_models\"]]}}}",
"async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}, \"sdkcore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"stdlib\": {\"typing\": [\"AsyncIterator\", \"IO\", \"Optional\", \"Union\"], \"io\": [\"IOBase\"]}, \"sdkcore\": {\"azure.core.polling\": [\"AsyncLROPoller\"], \"azure.core.async_paging\": [\"AsyncItemPaged\"]}, \"local\": {\"..\": [[\"models\", \"_models\"]]}}}",
"sync_mixin_typing_definitions": "",
"async_mixin_typing_definitions": "",
"operations": {
Expand Down Expand Up @@ -154,13 +154,13 @@
},
"begin_test_lro_and_paging" : {
"sync": {
"signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e LROPoller[Iterable[\"_models.Product\"]]:\n",
"signature": "def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e LROPoller[ItemPaged[\"_models.Product\"]]:\n",
"doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.LROPoller[~azure.core.paging.ItemPaged[~azure.multiapi.sample.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"",
"call": "client_request_id, test_lro_and_paging_options, **kwargs"
},
"async": {
"coroutine": true,
"signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncIterable[\"_models.Product\"]]:\n",
"signature": "async def begin_test_lro_and_paging(\n self,\n client_request_id: Optional[str] = None,\n test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,\n **kwargs: Any\n) -\u003e AsyncLROPoller[AsyncItemPaged[\"_models.Product\"]]:\n",
"doc": "\"\"\"A long-running paging operation that includes a nextLink that has 10 pages.\n\n:param client_request_id: Default value is None.\n:type client_request_id: str\n:param test_lro_and_paging_options: Parameter group. Default value is None.\n:type test_lro_and_paging_options: ~azure.multiapi.sample.v1.models.TestLroAndPagingOptions\n:return: An instance of LROPoller that returns an iterator like instance of either PagingResult\n or the result of cls(response)\n:rtype:\n ~azure.core.polling.AsyncLROPoller[~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v1.models.Product]]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"",
"call": "client_request_id, test_lro_and_paging_options, **kwargs"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, AsyncIterable, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
from typing import Any, AsyncIterator, Callable, Dict, IO, Optional, TypeVar, Union, cast, overload
import urllib.parse

from azure.core import AsyncPipelineClient
Expand Down Expand Up @@ -322,7 +322,7 @@ async def begin_test_lro_and_paging(
client_request_id: Optional[str] = None,
test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,
**kwargs: Any
) -> AsyncLROPoller[AsyncIterable["_models.Product"]]:
) -> AsyncLROPoller[AsyncItemPaged["_models.Product"]]:
"""A long-running paging operation that includes a nextLink that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -435,13 +435,13 @@ async def internal_get_next(next_link=None):
else:
polling_method = polling
if cont_token:
return AsyncLROPoller[AsyncIterable["_models.Product"]].from_continuation_token(
return AsyncLROPoller[AsyncItemPaged["_models.Product"]].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncLROPoller[AsyncIterable["_models.Product"]](
return AsyncLROPoller[AsyncItemPaged["_models.Product"]](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, Callable, Dict, IO, Iterable, Iterator, Optional, TypeVar, Union, cast, overload
from typing import Any, Callable, Dict, IO, Iterator, Optional, TypeVar, Union, cast, overload
import urllib.parse

from azure.core import PipelineClient
Expand Down Expand Up @@ -398,7 +398,7 @@ def begin_test_lro_and_paging(
client_request_id: Optional[str] = None,
test_lro_and_paging_options: Optional[_models.TestLroAndPagingOptions] = None,
**kwargs: Any
) -> LROPoller[Iterable["_models.Product"]]:
) -> LROPoller[ItemPaged["_models.Product"]]:
"""A long-running paging operation that includes a nextLink that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -511,13 +511,13 @@ def internal_get_next(next_link=None):
else:
polling_method = polling
if cont_token:
return LROPoller[Iterable["_models.Product"]].from_continuation_token(
return LROPoller[ItemPaged["_models.Product"]].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return LROPoller[Iterable["_models.Product"]](
return LROPoller[ItemPaged["_models.Product"]](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,20 +96,20 @@
"operation_group_two": "OperationGroupTwoOperations"
},
"operation_mixins": {
"sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Iterable\"]}}, \"regular\": {\"sdkcore\": {\"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"typing\": [\"Optional\"]}, \"local\": {\".\": [[\"models\", \"_models\"]]}}}",
"async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"AsyncIterable\"]}}, \"regular\": {\"sdkcore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}, \"stdlib\": {\"typing\": [\"Optional\"]}, \"local\": {\"..\": [[\"models\", \"_models\"]]}}}",
"sync_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}, \"sdkcore\": {\"azure.core.paging\": [\"ItemPaged\"]}}, \"regular\": {\"sdkcore\": {\"azure.core.paging\": [\"ItemPaged\"]}, \"stdlib\": {\"typing\": [\"Optional\"]}, \"local\": {\".\": [[\"models\", \"_models\"]]}}}",
"async_imports": "{\"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}, \"sdkcore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}}, \"regular\": {\"sdkcore\": {\"azure.core.async_paging\": [\"AsyncItemPaged\"]}, \"stdlib\": {\"typing\": [\"Optional\"]}, \"local\": {\"..\": [[\"models\", \"_models\"]]}}}",
"sync_mixin_typing_definitions": "",
"async_mixin_typing_definitions": "",
"operations": {
"test_paging" : {
"sync": {
"signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e Iterable[\"_models.ModelThree\"]:\n",
"signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e ItemPaged[\"_models.ModelThree\"]:\n",
"doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:return: An iterator like instance of either ModelThree or the result of cls(response)\n:rtype: ~azure.core.paging.ItemPaged[~azure.multiapi.sample.v3.models.ModelThree]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"",
"call": "**kwargs"
},
"async": {
"coroutine": false,
"signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncIterable[\"_models.ModelThree\"]:\n",
"signature": "def test_paging(\n self,\n **kwargs: Any\n) -\u003e AsyncItemPaged[\"_models.ModelThree\"]:\n",
"doc": "\"\"\"Returns ModelThree with optionalProperty \u0027paged\u0027.\n\n:return: An iterator like instance of either ModelThree or the result of cls(response)\n:rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.multiapi.sample.v3.models.ModelThree]\n:raises ~azure.core.exceptions.HttpResponseError:\n\"\"\"",
"call": "**kwargs"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
from typing import Any, Callable, Dict, Optional, TypeVar
import urllib.parse

from azure.core import AsyncPipelineClient
Expand Down Expand Up @@ -49,7 +49,7 @@ def _api_version(self, op_name: str) -> str: # pylint: disable=unused-argument
return ""

@distributed_trace
def test_paging(self, **kwargs: Any) -> AsyncIterable["_models.ModelThree"]:
def test_paging(self, **kwargs: Any) -> AsyncItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, AsyncIterable, Callable, Dict, IO, Optional, TypeVar, Union, overload
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse

from azure.core import AsyncPipelineClient
Expand Down Expand Up @@ -60,7 +60,7 @@ def __init__(self, *args, **kwargs) -> None:
self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")

@distributed_trace
def test_operation_group_paging(self, **kwargs: Any) -> AsyncIterable["_models.ModelThree"]:
def test_operation_group_paging(self, **kwargs: Any) -> AsyncItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from typing import Any, Callable, Dict, Iterable, Optional, TypeVar
from typing import Any, Callable, Dict, Optional, TypeVar
import urllib.parse

from azure.core import PipelineClient
Expand Down Expand Up @@ -91,7 +91,7 @@ def _api_version(self, op_name: str) -> str: # pylint: disable=unused-argument
return ""

@distributed_trace
def test_paging(self, **kwargs: Any) -> Iterable["_models.ModelThree"]:
def test_paging(self, **kwargs: Any) -> ItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# --------------------------------------------------------------------------
from collections.abc import MutableMapping
from io import IOBase
from typing import Any, Callable, Dict, IO, Iterable, Optional, TypeVar, Union, overload
from typing import Any, Callable, Dict, IO, Optional, TypeVar, Union, overload
import urllib.parse

from azure.core import PipelineClient
Expand Down Expand Up @@ -94,7 +94,7 @@ def __init__(self, *args, **kwargs) -> None:
self._api_version = input_args.pop(0) if input_args else kwargs.pop("api_version")

@distributed_trace
def test_operation_group_paging(self, **kwargs: Any) -> Iterable["_models.ModelThree"]:
def test_operation_group_paging(self, **kwargs: Any) -> ItemPaged["_models.ModelThree"]:
"""Returns ModelThree with optionalProperty 'paged'.

:return: An iterator like instance of either ModelThree or the result of cls(response)
Expand Down
Loading
Loading