Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Make the async adapter more generic
  • Loading branch information
lmazuel committed Jul 24, 2019
commit 3efd64af4f1e72c6b63702d96e971f9e8a50848c
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from typing import Any, Callable, Mapping, TYPE_CHECKING
from azure.core.async_paging import AsyncPagedMixin
from typing import Any, Callable, Mapping, AsyncIterator, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import AsyncPipeline
from azure.core.pipeline.policies.distributed_tracing import DistributedTracingPolicy
Expand All @@ -23,10 +22,10 @@


class AsyncPagingAdapter:
"""For each item in an AsyncPagedMixin, returns the result of applying fn to that item.
"""For each item in an AsyncIterator, returns the result of applying fn to that item.
Python 3.6 added syntax that could replace this (yield within async for)."""

def __init__(self, pages: AsyncPagedMixin, fn: Callable[[Model], Any]) -> None:
def __init__(self, pages: AsyncIterator, fn: Callable[[Model], Any]) -> None:
self._pages = pages
self._fn = fn

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.
# ------------------------------------
from typing import Any, Callable, Mapping, TYPE_CHECKING
from azure.core.async_paging import AsyncPagedMixin
from typing import Any, Callable, Mapping, AsyncIterator, TYPE_CHECKING
from azure.core.configuration import Configuration
from azure.core.pipeline import AsyncPipeline
from azure.core.pipeline.transport import AsyncioRequestsTransport, HttpTransport
Expand All @@ -22,10 +21,10 @@


class AsyncPagingAdapter:
"""For each item in an AsyncPagedMixin, returns the result of applying fn to that item.
"""For each item in an AsyncIterator, returns the result of applying fn to that item.
Python 3.6 added syntax that could replace this (yield within async for)."""

def __init__(self, pages: AsyncPagedMixin, fn: Callable[[Model], Any]) -> None:
def __init__(self, pages: AsyncIterator, fn: Callable[[Model], Any]) -> None:
self._pages = pages
self._fn = fn

Expand Down