Skip to content

Commit 82e2b54

Browse files
[translation] fix poller.details (Azure#20392)
* fixing docstring types for async client * populate poller.details.id immediately * pylint * add bug fix to changelog
1 parent 47108e9 commit 82e2b54

File tree

6 files changed

+15
-8
lines changed

6 files changed

+15
-8
lines changed

sdk/translation/azure-ai-translation-document/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
### Breaking Changes
88

99
### Bugs Fixed
10+
- The operation `id` under `details` of the poller object now populates correctly.
1011

1112
### Other Changes
1213

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/_polling.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,11 @@ def details(self):
6363
6464
:rtype: ~azure.ai.translation.document.TranslationStatus
6565
"""
66-
return TranslationStatus._from_generated( # pylint: disable=protected-access
67-
self._polling_method._current_body # pylint: disable=protected-access
68-
)
66+
if self._polling_method._current_body: # pylint: disable=protected-access
67+
return TranslationStatus._from_generated( # pylint: disable=protected-access
68+
self._polling_method._current_body # pylint: disable=protected-access
69+
)
70+
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
6971

7072
@classmethod
7173
def from_continuation_token(cls, polling_method, continuation_token, **kwargs):

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_async_polling.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def details(self) -> TranslationStatus:
4343
4444
:rtype: ~azure.ai.translation.document.TranslationStatus
4545
"""
46-
return TranslationStatus._from_generated( # pylint: disable=protected-access
47-
self._polling_method._current_body # pylint: disable=protected-access
48-
)
46+
if self._polling_method._current_body: # pylint: disable=protected-access
47+
return TranslationStatus._from_generated( # pylint: disable=protected-access
48+
self._polling_method._current_body # pylint: disable=protected-access
49+
)
50+
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
4951

5052
@classmethod
5153
def from_continuation_token(

sdk/translation/azure-ai-translation-document/azure/ai/translation/document/aio/_client_async.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def list_all_translation_statuses(self, **kwargs):
271271
format: ["param1 asc/desc", "param2 asc/desc", ...]
272272
(ex: 'created_on asc', 'created_on desc').
273273
:return: A pageable of TranslationStatus.
274-
:rtype: ~azure.core.paging.ItemPaged[TranslationStatus]
274+
:rtype: ~azure.core.async_paging.AsyncItemPaged[TranslationStatus]
275275
:raises ~azure.core.exceptions.HttpResponseError:
276276
277277
.. admonition:: Example:
@@ -336,7 +336,7 @@ def list_all_document_statuses(self, translation_id, **kwargs):
336336
format: ["param1 asc/desc", "param2 asc/desc", ...]
337337
(ex: 'created_on asc', 'created_on desc').
338338
:return: A pageable of DocumentStatus.
339-
:rtype: ~azure.core.paging.ItemPaged[DocumentStatus]
339+
:rtype: ~azure.core.async_paging.AsyncItemPaged[DocumentStatus]
340340
:raises ~azure.core.exceptions.HttpResponseError:
341341
342342
.. admonition:: Example:

sdk/translation/azure-ai-translation-document/tests/asynctestcase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ async def _begin_and_validate_translation_async(self, async_client, translation_
2626
# submit operation
2727
poller = await async_client.begin_translation(translation_inputs)
2828
self.assertIsNotNone(poller.id)
29+
self.assertIsNotNone(poller.details.id)
2930
# wait for result
3031
doc_statuses = await poller.result()
3132
# validate

sdk/translation/azure-ai-translation-document/tests/testcase.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -236,6 +236,7 @@ def _begin_and_validate_translation(self, client, translation_inputs, total_docs
236236
# submit job
237237
poller = client.begin_translation(translation_inputs)
238238
self.assertIsNotNone(poller.id)
239+
self.assertIsNotNone(poller.details.id)
239240
# wait for result
240241
result = poller.result()
241242
# validate

0 commit comments

Comments
 (0)