Skip to content

Commit e9bc674

Browse files
author
Mohamed Shaban
authored
Adding static checks (Azure#20457)
* added mypy configs * suppress false errors * discard remaining 'Any' type mismatch * adding translator package name to ci checks to run mypy * whitespace * fix pylint and mypy errors
1 parent 22d59ed commit e9bc674

File tree

6 files changed

+38
-25
lines changed

6 files changed

+38
-25
lines changed

eng/tox/mypy_hard_failure_packages.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
"azure-servicebus",
1414
"azure-ai-textanalytics",
1515
"azure-ai-formrecognizer",
16+
"azure-ai-translation-document",
1617
"azure-ai-metricsadvisor",
1718
"azure-eventgrid",
1819
"azure-appconfiguration",

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,13 +100,13 @@ def close(self):
100100
"""Close the :class:`~azure.ai.translation.document.DocumentTranslationClient` session."""
101101
return self._client.close()
102102

103-
@overload
104-
def begin_translation(self, source_url, target_url, target_language_code, **kwargs):
103+
@overload # type: ignore
104+
def begin_translation(self, source_url, target_url, target_language_code, **kwargs): # type: ignore
105105
# type: (str, str, str, **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatus]]
106106
pass
107107

108-
@overload
109-
def begin_translation(self, inputs, **kwargs):
108+
@overload # type: ignore
109+
def begin_translation(self, inputs, **kwargs): # type: ignore
110110
# type: (List[DocumentTranslationInput], **Any) -> DocumentTranslationLROPoller[ItemPaged[DocumentStatus]]
111111
pass
112112

@@ -301,7 +301,7 @@ def _convert_from_generated_model(
301301
],
302302
)
303303

304-
return self._client.document_translation.get_translations_status(
304+
return self._client.document_translation.get_translations_status( # type: ignore
305305
cls=model_conversion_function,
306306
maxpagesize=results_per_page,
307307
created_date_time_utc_start=created_after,
@@ -375,7 +375,7 @@ def _convert_from_generated_model(generated_model):
375375
],
376376
)
377377

378-
return self._client.document_translation.get_documents_status(
378+
return self._client.document_translation.get_documents_status( # type: ignore
379379
id=translation_id,
380380
cls=model_conversion_function,
381381
maxpagesize=results_per_page,

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ def id(self):
4848
4949
:rtype: str
5050
"""
51-
if self._polling_method._current_body: # pylint: disable=protected-access
51+
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
5252
return (
53-
self._polling_method._current_body.id # pylint: disable=protected-access
53+
self._polling_method._current_body.id # type: ignore # pylint: disable=protected-access
5454
)
5555
return (
56-
self._polling_method._get_id_from_headers() # pylint: disable=protected-access
56+
self._polling_method._get_id_from_headers() # type: ignore # pylint: disable=protected-access
5757
)
5858

5959
@property
@@ -63,14 +63,14 @@ def details(self):
6363
6464
:rtype: ~azure.ai.translation.document.TranslationStatus
6565
"""
66-
if self._polling_method._current_body: # pylint: disable=protected-access
66+
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
6767
return TranslationStatus._from_generated( # pylint: disable=protected-access
68-
self._polling_method._current_body # pylint: disable=protected-access
68+
self._polling_method._current_body # type: ignore # pylint: disable=protected-access
6969
)
70-
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
70+
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # type: ignore # pylint: disable=protected-access
7171

7272
@classmethod
73-
def from_continuation_token(cls, polling_method, continuation_token, **kwargs):
73+
def from_continuation_token(cls, polling_method, continuation_token, **kwargs): # type: ignore
7474
# type: (DocumentTranslationLROPollingMethod, str, **Any) -> DocumentTranslationLROPoller
7575

7676
(
@@ -124,7 +124,7 @@ def get_continuation_token(self):
124124
return self._current_body.id
125125
return self._get_id_from_headers()
126126

127-
def from_continuation_token(self, continuation_token, **kwargs):
127+
def from_continuation_token(self, continuation_token, **kwargs): # type: ignore
128128
# type: (str, Any) -> Tuple
129129
try:
130130
client = kwargs["client"]

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,12 @@ def id(self) -> str:
2929
3030
:rtype: str
3131
"""
32-
if self._polling_method._current_body: # pylint: disable=protected-access
32+
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
3333
return (
34-
self._polling_method._current_body.id # pylint: disable=protected-access
34+
self._polling_method._current_body.id # type: ignore # pylint: disable=protected-access
3535
)
3636
return (
37-
self._polling_method._get_id_from_headers() # pylint: disable=protected-access
37+
self._polling_method._get_id_from_headers() # type: ignore # pylint: disable=protected-access
3838
)
3939

4040
@property
@@ -43,14 +43,14 @@ def details(self) -> TranslationStatus:
4343
4444
:rtype: ~azure.ai.translation.document.TranslationStatus
4545
"""
46-
if self._polling_method._current_body: # pylint: disable=protected-access
46+
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
4747
return TranslationStatus._from_generated( # pylint: disable=protected-access
48-
self._polling_method._current_body # pylint: disable=protected-access
48+
self._polling_method._current_body # type: ignore # pylint: disable=protected-access
4949
)
50-
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
50+
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # type: ignore # pylint: disable=protected-access
5151

5252
@classmethod
53-
def from_continuation_token(
53+
def from_continuation_token( # type: ignore
5454
cls,
5555
polling_method: "AsyncDocumentTranslationLROPollingMethod",
5656
continuation_token: str,
@@ -63,7 +63,7 @@ def from_continuation_token(
6363
deserialization_callback,
6464
) = polling_method.from_continuation_token(continuation_token, **kwargs)
6565

66-
return cls(client, initial_response, deserialization_callback, polling_method)
66+
return cls(client, initial_response, deserialization_callback, polling_method) # type: ignore
6767

6868

6969
class AsyncDocumentTranslationLROPollingMethod(AsyncLROBasePolling):
@@ -105,7 +105,7 @@ def get_continuation_token(self) -> str:
105105
return self._current_body.id
106106
return self._get_id_from_headers()
107107

108-
def from_continuation_token(self, continuation_token: str, **kwargs: Any) -> Tuple:
108+
def from_continuation_token(self, continuation_token: str, **kwargs: Any) -> Tuple: # type: ignore
109109
try:
110110
client = kwargs["client"]
111111
except KeyError:

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
@@ -310,7 +310,7 @@ def _convert_from_generated_model(generated_model):
310310
],
311311
)
312312

313-
return self._client.document_translation.get_translations_status(
313+
return self._client.document_translation.get_translations_status( # type: ignore
314314
cls=model_conversion_function,
315315
maxpagesize=results_per_page,
316316
created_date_time_utc_start=created_after,
@@ -383,7 +383,7 @@ def _convert_from_generated_model(generated_model):
383383
],
384384
)
385385

386-
return self._client.document_translation.get_documents_status(
386+
return self._client.document_translation.get_documents_status( # type: ignore
387387
id=translation_id,
388388
cls=model_conversion_function,
389389
maxpagesize=results_per_page,
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[mypy]
2+
python_version = 3.6
3+
warn_unused_configs = True
4+
ignore_missing_imports = True
5+
6+
# Per-module options:
7+
8+
[mypy-azure.ai.translation.document._generated.*]
9+
ignore_errors = True
10+
11+
[mypy-azure.core.*]
12+
ignore_errors = True

0 commit comments

Comments
 (0)