From f349ea6dbd2a407024602d738f52378383a54042 Mon Sep 17 00:00:00 2001 From: Laurent Mazuel Date: Wed, 31 Jul 2019 18:04:30 -0700 Subject: [PATCH] azure-core black/pylint/mypy (#6581) * Pylint/black happyness * mypy * Fix exceptiont tests * bad-continuation ignroe by defulat --- pylintrc | 3 ++- sdk/core/azure-core/azure/core/async_paging.py | 7 +++++-- sdk/core/azure-core/azure/core/exceptions.py | 8 ++++---- sdk/core/azure-core/azure/core/paging.py | 4 ++-- sdk/core/azure-core/azure/core/pipeline/__init__.py | 2 +- 5 files changed, 14 insertions(+), 10 deletions(-) diff --git a/pylintrc b/pylintrc index 1547d565944f..b1b9d2d5e29e 100644 --- a/pylintrc +++ b/pylintrc @@ -7,7 +7,8 @@ reports=no # locally-disabled: Warning locally suppressed using disable-msg # cyclic-import: because of https://github.com/PyCQA/pylint/issues/850 # too-many-arguments: Due to the nature of the CLI many commands have large arguments set which reflect in large arguments set in corresponding methods. -disable=useless-object-inheritance,missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods +# Let's black deal with bad-continuation +disable=useless-object-inheritance,missing-docstring,locally-disabled,fixme,cyclic-import,too-many-arguments,invalid-name,duplicate-code,too-few-public-methods,bad-continuation [FORMAT] max-line-length=120 diff --git a/sdk/core/azure-core/azure/core/async_paging.py b/sdk/core/azure-core/azure/core/async_paging.py index 8a61c5b00ddc..e013f41df7ee 100644 --- a/sdk/core/azure-core/azure/core/async_paging.py +++ b/sdk/core/azure-core/azure/core/async_paging.py @@ -64,7 +64,9 @@ async def __anext__(self) -> ReturnType: class AsyncPageIterator(AsyncIterator[AsyncIterator[ReturnType]]): def __init__( self, - get_next: Callable[[Optional[str]], Awaitable[ResponseType]], + get_next: Callable[ + [Optional[str]], Awaitable[ResponseType] + ], extract_data: Callable[ [ResponseType], Awaitable[Tuple[str, AsyncIterator[ReturnType]]] ], @@ -120,7 +122,8 @@ def __init__(self, *args, **kwargs) -> None: ) def by_page( - self, continuation_token: Optional[str] = None + self, + continuation_token: Optional[str] = None, ) -> AsyncIterator[AsyncIterator[ReturnType]]: """Get an async iterator of pages of objects, instead of an async iterator of objects. diff --git a/sdk/core/azure-core/azure/core/exceptions.py b/sdk/core/azure-core/azure/core/exceptions.py index b69912108a40..da90c32bdd4c 100644 --- a/sdk/core/azure-core/azure/core/exceptions.py +++ b/sdk/core/azure-core/azure/core/exceptions.py @@ -28,7 +28,7 @@ import logging import sys -from typing import Callable, Any, Dict, Optional, TYPE_CHECKING +from typing import Callable, Any, Dict, Optional, List, Union, TYPE_CHECKING _LOGGER = logging.getLogger(__name__) @@ -237,10 +237,10 @@ class ODataV4Error(HttpResponseError): _ERROR_FORMAT = ODataV4Format def __init__(self, response, **kwargs): - # type: (_HttpResponseBase, Dict[str, Any]) -> None + # type: (_HttpResponseBase, Any) -> None # Ensure field are declared, whatever can happen afterwards - self.odata_json = None # type: Optional[dict[str, Any]] + self.odata_json = None # type: Optional[Dict[str, Any]] try: self.odata_json = json.loads(response.text()) odata_message = self.odata_json.setdefault("error", {}).get("message") @@ -259,7 +259,7 @@ def __init__(self, response, **kwargs): super(ODataV4Error, self).__init__(response=response, **kwargs) - self._error_format = None + self._error_format = None # type: Optional[Union[str, ODataV4Format]] if self.odata_json: try: error_node = self.odata_json["error"] diff --git a/sdk/core/azure-core/azure/core/paging.py b/sdk/core/azure-core/azure/core/paging.py index 9f4089d02099..ca00c81cc356 100644 --- a/sdk/core/azure-core/azure/core/paging.py +++ b/sdk/core/azure-core/azure/core/paging.py @@ -24,14 +24,14 @@ # # -------------------------------------------------------------------------- import itertools -from typing import ( +from typing import ( # pylint: disable=unused-import Callable, Optional, TypeVar, Iterator, Iterable, Tuple, -) # pylint: disable=unused-import +) import logging diff --git a/sdk/core/azure-core/azure/core/pipeline/__init__.py b/sdk/core/azure-core/azure/core/pipeline/__init__.py index 2df1fbfea898..a4dad249a355 100644 --- a/sdk/core/azure-core/azure/core/pipeline/__init__.py +++ b/sdk/core/azure-core/azure/core/pipeline/__init__.py @@ -109,7 +109,7 @@ class PipelineRequest(object): :type context: ~azure.core.pipeline.PipelineContext """ def __init__(self, http_request, context): - # type: (HTTPRequestType, Optional[Any]) -> None + # type: (HTTPRequestType, PipelineContext) -> None self.http_request = http_request self.context = context