Skip to content

Commit 3650134

Browse files
[textanalytics] arch feedback (Azure#25453)
* remove polling_method from protocol and make covariant * update docstrings * pylint
1 parent f00689f commit 3650134

File tree

4 files changed

+166
-100
lines changed

4 files changed

+166
-100
lines changed

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_base_client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717
class TextAnalyticsApiVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta):
1818
"""Cognitive Service for Language or Text Analytics API versions supported by this package"""
1919

20-
#: this is the default version
20+
#: This is the default version and corresponds to the Cognitive Service for Language API.
2121
V2022_05_01 = "2022-05-01"
22+
#: This version corresponds to Text Analytics API.
2223
V3_1 = "v3.1"
24+
#: This version corresponds to Text Analytics API.
2325
V3_0 = "v3.0"
2426

2527

sdk/textanalytics/azure-ai-textanalytics/azure/ai/textanalytics/_lro.py

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
from urllib.parse import urlencode
1010
from typing import Any, Mapping, Optional, Callable, TypeVar, cast
1111
from typing_extensions import Protocol, runtime_checkable
12-
from azure.core.polling import PollingMethod
1312
from azure.core.exceptions import HttpResponseError
1413
from azure.core.polling import LROPoller
1514
from azure.core.polling.base_polling import (
@@ -25,7 +24,7 @@
2524
_SUCCEEDED = frozenset(["succeeded", "partiallycompleted", "partiallysucceeded"])
2625

2726

28-
PollingReturnType = TypeVar("PollingReturnType")
27+
PollingReturnType = TypeVar("PollingReturnType", covariant=True)
2928

3029

3130
@runtime_checkable
@@ -35,34 +34,74 @@ class TextAnalysisLROPoller(Protocol[PollingReturnType]):
3534

3635
@property
3736
def details(self) -> Mapping[str, Any]:
38-
...
37+
"""Long-running operation metadata.
3938
40-
def polling_method(self) -> PollingMethod[PollingReturnType]: # pylint: disable=no-self-use
41-
...
39+
:return: A mapping of details about the long-running operation.
40+
:rtype: Mapping[str, Any]
41+
"""
4242

4343
def continuation_token(self) -> str: # pylint: disable=no-self-use
44-
...
44+
"""Return a continuation token that allows to restart the poller later.
45+
46+
:returns: An opaque continuation token
47+
:rtype: str
48+
"""
4549

4650
def status(self) -> str: # pylint: disable=no-self-use
47-
...
51+
"""Returns the current status string.
52+
53+
:returns: The current status string
54+
:rtype: str
55+
"""
4856

4957
def result(self, timeout: Optional[int] = None) -> PollingReturnType: # pylint: disable=no-self-use, unused-argument
50-
...
58+
"""Return the result of the long running operation, or
59+
the result available after the specified timeout.
60+
61+
:returns: The deserialized resource of the long running operation,
62+
if one is available.
63+
:raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
64+
"""
5165

5266
def wait(self, timeout: Optional[float] = None) -> None: # pylint: disable=no-self-use, unused-argument
53-
...
67+
"""Wait on the long running operation for a specified length
68+
of time. You can check if this call as ended with timeout with the
69+
"done()" method.
70+
71+
:param float timeout: Period of time to wait for the long running
72+
operation to complete (in seconds).
73+
:raises ~azure.core.exceptions.HttpResponseError: Server problem with the query.
74+
"""
5475

5576
def done(self) -> bool: # pylint: disable=no-self-use
56-
...
77+
"""Check status of the long running operation.
78+
79+
:returns: 'True' if the process has completed, else 'False'.
80+
:rtype: bool
81+
"""
5782

5883
def add_done_callback(self, func: Callable) -> None: # pylint: disable=no-self-use, unused-argument
59-
...
84+
"""Add callback function to be run once the long running operation
85+
has completed - regardless of the status of the operation.
86+
87+
:param callable func: Callback function that takes at least one
88+
argument, a completed LongRunningOperation.
89+
"""
6090

6191
def remove_done_callback(self, func: Callable) -> None: # pylint: disable=no-self-use, unused-argument
62-
...
92+
"""Remove a callback from the long running operation.
93+
94+
:param callable func: The function to be removed from the callbacks.
95+
:raises ValueError: if the long running operation has already completed.
96+
"""
6397

6498
def cancel(self) -> None: # pylint: disable=no-self-use
65-
...
99+
"""Cancel the operation currently being polled.
100+
101+
:return: None
102+
:rtype: None
103+
:raises ~azure.core.exceptions.HttpResponseError: When the operation has already reached a terminal state.
104+
"""
66105

67106

68107
class TextAnalyticsOperationResourcePolling(OperationResourcePolling):

0 commit comments

Comments
 (0)