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

[Storage Blob] pylint + mypy passs #6175

Merged
merged 2 commits into from
Jun 29, 2019
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
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import os

from typing import Union, Iterable, AnyStr, IO, Any # pylint: disable=unused-import
from .version import VERSION
from .blob_client import BlobClient
from .container_client import ContainerClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

import sys
from io import BytesIO, SEEK_SET, UnsupportedOperation
from typing import Optional, Union, Any, TypeVar, TYPE_CHECKING # pylint: disable=unused-import

import six
from azure.core.exceptions import ResourceExistsError, ResourceModifiedError
Expand Down Expand Up @@ -39,6 +40,9 @@
)
from .models import BlobProperties, ContainerProperties

if TYPE_CHECKING:
from datetime import datetime # pylint: disable=unused-import
LeaseClient = TypeVar("LeaseClient")

_LARGE_BLOB_UPLOAD_MAX_READ_BUFFER_SIZE = 4 * 1024 * 1024
_ERROR_VALUE_SHOULD_BE_SEEKABLE_STREAM = '{0} should be a seekable file-like/io.IOBase type stream object.'
Expand All @@ -60,9 +64,9 @@ def _convert_mod_error(error):
def get_access_conditions(lease):
# type: (Optional[Union[LeaseClient, str]]) -> Union[LeaseAccessConditions, None]
try:
lease_id = lease.id
lease_id = lease.id # type: ignore
except AttributeError:
lease_id = lease
lease_id = lease # type: ignore
return LeaseAccessConditions(lease_id=lease_id) if lease_id else None


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
try:
from urllib.parse import urlparse, unquote
except ImportError:
from urlparse import urlparse
from urllib2 import unquote
from urlparse import urlparse # type: ignore
from urllib2 import unquote # type: ignore

from azure.core.exceptions import ClientAuthenticationError
from azure.core.pipeline.policies import SansIOHTTPPolicy
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
if sys.version_info >= (3, 5):
# the timeout to connect is 20 seconds, and the read timeout is 2000 seconds
# the 2000 seconds was calculated with: 100MB (max block size)/ 50KB/s (an arbitrarily chosen minimum upload speed)
DEFAULT_SOCKET_TIMEOUT = (20, 2000)
DEFAULT_SOCKET_TIMEOUT = (20, 2000) # type: ignore

STORAGE_OAUTH_SCOPE = "https://storage.azure.com/.default"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ def __str__(self):
('f' if self.file else ''))


Services.BLOB = Services(blob=True)
Services.QUEUE = Services(queue=True)
Services.TABLE = Services(table=True)
Services.FILE = Services(file=True)
Services.BLOB = Services(blob=True) # type: ignore
Services.QUEUE = Services(queue=True) # type: ignore
Services.TABLE = Services(table=True) # type: ignore
Services.FILE = Services(file=True) # type: ignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import uuid
import types
import platform
from typing import Any, TYPE_CHECKING
from wsgiref.handlers import format_date_time
try:
from urllib.parse import (
Expand All @@ -23,8 +24,8 @@
urlencode,
)
except ImportError:
from urllib import urlencode
from urlparse import (
from urllib import urlencode # type: ignore
from urlparse import ( # type: ignore
urlparse,
parse_qsl,
urlunparse,
Expand All @@ -42,10 +43,13 @@
from .models import LocationMode

try:
_unicode_type = unicode
_unicode_type = unicode # type: ignore
except NameError:
_unicode_type = str

if TYPE_CHECKING:
from azure.core.pipeline import PipelineRequest, PipelineResponse


_LOGGER = logging.getLogger(__name__)

Expand Down Expand Up @@ -274,7 +278,7 @@ def __init__(self, **kwargs): # pylint: disable=unused-argument
super(StorageRequestHook, self).__init__()

def on_request(self, request, **kwargs):
# type: (PipelineRequest) -> PipelineResponse
# type: (PipelineRequest, **Any) -> PipelineResponse
request_callback = request.context.options.pop('raw_request_hook', self._request_callback)
if request_callback:
request_callback(request)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# --------------------------------------------------------------------------

from typing import ( # pylint: disable=unused-import
Union, Optional, Any, Iterable, Dict, List, Type,
Union, Optional, Any, Iterable, Dict, List, Type, Tuple,
TYPE_CHECKING
)
import base64
Expand All @@ -18,8 +18,8 @@
try:
from urllib.parse import quote, unquote, parse_qs
except ImportError:
from urlparse import parse_qs
from urllib2 import quote, unquote
from urlparse import parse_qs # type: ignore
from urllib2 import quote, unquote # type: ignore

import six
import isodate
Expand Down Expand Up @@ -118,7 +118,7 @@ def to_list():
class StorageAccountHostsMixin(object):

def __init__(
self, parsed_url, # type: str
self, parsed_url, # type: Any
service, # type: str
credential=None, # type: Optional[Any]
**kwargs # type: Any
Expand Down Expand Up @@ -485,7 +485,7 @@ def create_configuration(**kwargs):


def create_pipeline(credential, **kwargs):
# type: (Configuration, Optional[HTTPPolicy], **Any) -> Tuple[Configuration, Pipeline]
# type: (Any, **Any) -> Tuple[Configuration, Pipeline]
credential_policy = None
if hasattr(credential, 'get_token'):
credential_policy = BearerTokenCredentialPolicy(credential, STORAGE_OAUTH_SCOPE)
Expand Down Expand Up @@ -540,7 +540,6 @@ def is_credential_sastoken(credential):


def add_metadata_headers(metadata):
# type: (Dict[str, str]) -> Dict[str, str]
headers = {}
if metadata:
for key, value in metadata.items():
Expand Down
Loading