microsoft / microsoft/typespec

[python] Add support for paging through callbacks as kwargs

Open
#5,770 0 comments 0 reactions 1 assignee Claimed by @iscai-msft View on GitHub
emitter:client:python
Dominant language
Java
Stars
5.9k
Forks
394
Avg merge
1d 23h
Merged PRs (30d)
104

Description

Original issue [here](https://github.com/Azure/autorest.python/issues/665).

Expected syntax for code user:

```python
from azure.core.paging import PagingMethod

class SearchPaging(PagingMethod):
def __init__(self, *args, **kwargs):
# do things

def get_next(self, continuation_token):
# do things
return get_next_return

def extract_data(get_next_return):
# do things
return continuation_token, current_page

pager = client.list_all(paging=SearchPaging(**params))

for item in pager:
print(item)
```

Azure-core impact:
```python
class PagingMethod(abc):

@abc.abstractmethod
def get_next(self, continuation_token):
# do things
return get_next_return

@abc.abstractmethod
def extract_data(get_next_return):
# do things
return continuation_token, current_page

# FIXME
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.