Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding static checks #20457

Merged
merged 6 commits into from
Aug 31, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
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
1 change: 1 addition & 0 deletions eng/tox/mypy_hard_failure_packages.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"azure-servicebus",
"azure-ai-textanalytics",
"azure-ai-formrecognizer",
"azure-ai-translation-document",
"azure-ai-metricsadvisor",
"azure-eventgrid",
"azure-appconfiguration",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,13 @@ def close(self):
"""Close the :class:`~azure.ai.translation.document.DocumentTranslationClient` session."""
return self._client.close()

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

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

Expand Down Expand Up @@ -301,7 +301,7 @@ def _convert_from_generated_model(
],
)

return self._client.document_translation.get_translations_status(
return self._client.document_translation.get_translations_status( # type: ignore
cls=model_conversion_function,
maxpagesize=results_per_page,
created_date_time_utc_start=created_after,
Expand Down Expand Up @@ -375,7 +375,7 @@ def _convert_from_generated_model(generated_model):
],
)

return self._client.document_translation.get_documents_status(
return self._client.document_translation.get_documents_status( # type: ignore
id=translation_id,
cls=model_conversion_function,
maxpagesize=results_per_page,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,12 @@ def id(self):

:rtype: str
"""
if self._polling_method._current_body: # pylint: disable=protected-access
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
return (
self._polling_method._current_body.id # pylint: disable=protected-access
self._polling_method._current_body.id # type: ignore # pylint: disable=protected-access
)
return (
self._polling_method._get_id_from_headers() # pylint: disable=protected-access
self._polling_method._get_id_from_headers() # type: ignore # pylint: disable=protected-access
)

@property
Expand All @@ -63,14 +63,14 @@ def details(self):

:rtype: ~azure.ai.translation.document.TranslationStatus
"""
if self._polling_method._current_body: # pylint: disable=protected-access
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
return TranslationStatus._from_generated( # pylint: disable=protected-access
self._polling_method._current_body # pylint: disable=protected-access
self._polling_method._current_body # type: ignore # pylint: disable=protected-access
)
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # type: ignore # pylint: disable=protected-access

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

(
Expand Down Expand Up @@ -124,7 +124,7 @@ def get_continuation_token(self):
return self._current_body.id
return self._get_id_from_headers()

def from_continuation_token(self, continuation_token, **kwargs):
def from_continuation_token(self, continuation_token, **kwargs): # type: ignore
# type: (str, Any) -> Tuple
try:
client = kwargs["client"]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,12 @@ def id(self) -> str:

:rtype: str
"""
if self._polling_method._current_body: # pylint: disable=protected-access
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
return (
self._polling_method._current_body.id # pylint: disable=protected-access
self._polling_method._current_body.id # type: ignore # pylint: disable=protected-access
)
return (
self._polling_method._get_id_from_headers() # pylint: disable=protected-access
self._polling_method._get_id_from_headers() # type: ignore # pylint: disable=protected-access
)

@property
Expand All @@ -43,14 +43,14 @@ def details(self) -> TranslationStatus:

:rtype: ~azure.ai.translation.document.TranslationStatus
"""
if self._polling_method._current_body: # pylint: disable=protected-access
if self._polling_method._current_body: # type: ignore # pylint: disable=protected-access
return TranslationStatus._from_generated( # pylint: disable=protected-access
self._polling_method._current_body # pylint: disable=protected-access
self._polling_method._current_body # type: ignore # pylint: disable=protected-access
)
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # pylint: disable=protected-access
return TranslationStatus(id=self._polling_method._get_id_from_headers()) # type: ignore # pylint: disable=protected-access

@classmethod
def from_continuation_token(
def from_continuation_token( # type: ignore
cls,
polling_method: "AsyncDocumentTranslationLROPollingMethod",
continuation_token: str,
Expand All @@ -63,7 +63,7 @@ def from_continuation_token(
deserialization_callback,
) = polling_method.from_continuation_token(continuation_token, **kwargs)

return cls(client, initial_response, deserialization_callback, polling_method)
return cls(client, initial_response, deserialization_callback, polling_method) # type: ignore


class AsyncDocumentTranslationLROPollingMethod(AsyncLROBasePolling):
Expand Down Expand Up @@ -105,7 +105,7 @@ def get_continuation_token(self) -> str:
return self._current_body.id
return self._get_id_from_headers()

def from_continuation_token(self, continuation_token: str, **kwargs: Any) -> Tuple:
def from_continuation_token(self, continuation_token: str, **kwargs: Any) -> Tuple: # type: ignore
try:
client = kwargs["client"]
except KeyError:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ def _convert_from_generated_model(generated_model):
],
)

return self._client.document_translation.get_translations_status(
return self._client.document_translation.get_translations_status( # type: ignore
cls=model_conversion_function,
maxpagesize=results_per_page,
created_date_time_utc_start=created_after,
Expand Down Expand Up @@ -383,7 +383,7 @@ def _convert_from_generated_model(generated_model):
],
)

return self._client.document_translation.get_documents_status(
return self._client.document_translation.get_documents_status( # type: ignore
id=translation_id,
cls=model_conversion_function,
maxpagesize=results_per_page,
Expand Down
12 changes: 12 additions & 0 deletions sdk/translation/azure-ai-translation-document/mypy.ini
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[mypy]
python_version = 3.6
warn_unused_configs = True
ignore_missing_imports = True

# Per-module options:

[mypy-azure.ai.translation.document._generated.*]
ignore_errors = True

[mypy-azure.core.*]
ignore_errors = True