Skip to content
Open
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: internal
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

add baseline of generated code before regenerate to contain necessary customized code for some specific test cases
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
changeKind: fix
packages:
- "@autorest/python"
- "@azure-tools/typespec-python"
---

Fix typing in generated paging operations when an operation is named `list` and the page item is a collection type. The return type annotation now correctly uses the `List` alias (e.g. `AsyncItemPaged[List[str]]`) instead of the built-in `list` (which would shadow the operation name) to stay consistent with other annotations in the same file.
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": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNjI0NjE0NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.28.3.tgz",
"@typespec/http-client-python": "https://artprodcus3.artifacts.visualstudio.com/A0fb41ef4-5012-48a9-bf39-4ee3de03ee35/29ec6040-b234-4e31-b139-33dc4287b756/_apis/artifact/cGlwZWxpbmVhcnRpZmFjdDovL2F6dXJlLXNkay9wcm9qZWN0SWQvMjllYzYwNDAtYjIzNC00ZTMxLWIxMzktMzNkYzQyODdiNzU2L2J1aWxkSWQvNjI3ODE4NC9hcnRpZmFjdE5hbWUvYnVpbGRfYXJ0aWZhY3RzX3B5dGhvbg2/content?format=file&subPath=%2Fpackages%2Ftypespec-http-client-python-0.28.3.tgz",
"@autorest/system-requirements": "~1.0.2",
"fs-extra": "~11.2.0",
"tsx": "^4.21.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def __init__(self, *args, **kwargs) -> None:
self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")

@distributed_trace
def get_no_item_name_pages(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_no_item_name_pages(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that must return result of the default 'value' node.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -163,7 +163,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_empty_next_link_name_pages(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_empty_next_link_name_pages(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that gets an empty next link and should stop after page 1.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -237,7 +237,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_null_next_link_name_pages(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_null_next_link_name_pages(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that must ignore any kind of nextLink, and stop after page 1.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -311,7 +311,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_single_pages(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_single_pages(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that finishes on the first call without a nextlink.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -387,7 +387,7 @@ async def get_next(next_link=None):
@distributed_trace
def get_single_pages_with_body_params(
self, name: Optional[str] = None, **kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that finishes on the first call with body params without a nextlink.

:param name: Default value is None.
Expand Down Expand Up @@ -468,7 +468,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def first_response_empty(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def first_response_empty(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation whose first response's items list is empty, but still returns a next link.
Second (and final) call, will give you an items list of 1.

Expand Down Expand Up @@ -548,7 +548,7 @@ def get_multiple_pages(
client_request_id: Optional[str] = None,
paging_get_multiple_pages_options: Optional[_models.PagingGetMultiplePagesOptions] = None,
**kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that includes a nextLink that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -635,7 +635,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_with_query_params(self, required_query_parameter: int, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_with_query_params(self, required_query_parameter: int, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that includes a next operation. It has a different query parameter from it's
next operation nextOperationWithQueryParams. Returns a ProductResult.

Expand Down Expand Up @@ -707,7 +707,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def duplicate_params(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def duplicate_params(self, filter: Optional[str] = None, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""Define ``filter`` as a query param for all calls. However, the returned next link will also
include the ``filter`` as part of it. Make sure you don't end up duplicating the ``filter``
param in the url sent.
Expand Down Expand Up @@ -788,7 +788,7 @@ async def get_next(next_link=None):
@distributed_trace
def page_with_max_page_size(
self, maxpagesize: Literal["5"] = "5", **kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""Paging with max page size. We don't want to.

:param maxpagesize: Max page size query param. Don't send. Known values are "5" and None.
Expand Down Expand Up @@ -871,7 +871,7 @@ def get_odata_multiple_pages(
client_request_id: Optional[str] = None,
paging_get_odata_multiple_pages_options: Optional[_models.PagingGetOdataMultiplePagesOptions] = None,
**kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that includes a nextLink in odata format that has 10 pages.

:param client_request_id: Default value is None.
Expand Down Expand Up @@ -963,7 +963,7 @@ def get_multiple_pages_with_offset(
paging_get_multiple_pages_with_offset_options: _models.PagingGetMultiplePagesWithOffsetOptions,
client_request_id: Optional[str] = None,
**kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that includes a nextLink that has 10 pages.

:param paging_get_multiple_pages_with_offset_options: Parameter group. Required.
Expand Down Expand Up @@ -1053,7 +1053,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_multiple_pages_retry_first(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_multiple_pages_retry_first(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that fails on the first call with 500 and then retries and then get a
response including a nextLink that has 10 pages.

Expand Down Expand Up @@ -1128,7 +1128,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_multiple_pages_retry_second(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_multiple_pages_retry_second(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that includes a nextLink that has 10 pages, of which the 2nd call fails
first with 500. The client should retry and finish all 10 pages eventually.

Expand Down Expand Up @@ -1203,7 +1203,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_single_pages_failure(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_single_pages_failure(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that receives a 400 on the first call.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -1277,7 +1277,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_multiple_pages_failure(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_multiple_pages_failure(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that receives a 400 on the second call.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -1351,7 +1351,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def get_multiple_pages_failure_uri(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def get_multiple_pages_failure_uri(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation that receives an invalid nextLink.

:return: An iterator like instance of either Product or the result of cls(response)
Expand Down Expand Up @@ -1427,7 +1427,7 @@ async def get_next(next_link=None):
@distributed_trace
def get_multiple_pages_fragment_next_link(
self, api_version: str, tenant: str, **kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that doesn't return a full URL, just a fragment.

:param api_version: Sets the api version to use. Required.
Expand Down Expand Up @@ -1502,7 +1502,7 @@ async def get_next(next_link=None):
@distributed_trace
def get_multiple_pages_fragment_with_grouping_next_link( # pylint: disable=name-too-long
self, custom_parameter_group: _models.CustomParameterGroup, **kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that doesn't return a full URL, just a fragment with parameters grouped.

:param custom_parameter_group: Parameter group. Required.
Expand Down Expand Up @@ -1645,7 +1645,7 @@ async def begin_get_multiple_pages_lro(
client_request_id: Optional[str] = None,
paging_get_multiple_pages_lro_options: Optional[_models.PagingGetMultiplePagesLroOptions] = None,
**kwargs: Any
) -> AsyncCustomPoller[AsyncItemPaged["_models.Product"]]:
) -> AsyncCustomPoller[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 @@ -1762,18 +1762,18 @@ async def internal_get_next(next_link=None):
else:
polling_method = polling
if cont_token:
return AsyncCustomPoller[AsyncItemPaged["_models.Product"]].from_continuation_token(
return AsyncCustomPoller[AsyncItemPaged[_models.Product]].from_continuation_token(
polling_method=polling_method,
continuation_token=cont_token,
client=self._client,
deserialization_callback=get_long_running_output,
)
return AsyncCustomPoller[AsyncItemPaged["_models.Product"]](
return AsyncCustomPoller[AsyncItemPaged[_models.Product]](
self._client, raw_result, get_long_running_output, polling_method # type: ignore
)

@distributed_trace
def append_api_version(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def append_api_version(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation with api version. When calling the next link, you want to append your
client's api version to the next link.

Expand Down Expand Up @@ -1850,7 +1850,7 @@ async def get_next(next_link=None):
return AsyncItemPaged(get_next, extract_data)

@distributed_trace
def replace_api_version(self, **kwargs: Any) -> AsyncItemPaged["_models.Product"]:
def replace_api_version(self, **kwargs: Any) -> AsyncItemPaged[_models.Product]:
"""A paging operation with api version. When calling the next link, you want to reformat it and
override the returned api version with your client's api version.

Expand Down Expand Up @@ -1929,7 +1929,7 @@ async def get_next(next_link=None):
@distributed_trace
def get_paging_model_with_item_name_with_xms_client_name( # pylint: disable=name-too-long
self, **kwargs: Any
) -> AsyncItemPaged["_models.Product"]:
) -> AsyncItemPaged[_models.Product]:
"""A paging operation that returns a paging model whose item name is is overriden by
x-ms-client-name 'indexes'.

Expand Down
Loading
Loading