Skip to content

Commit 68bc8c3

Browse files
updating pylint statements (Azure#16362)
Removes unnecessary pylint statements, changes numbers to descriptions, makes a few code changes to address a pylint issue
1 parent ad5308d commit 68bc8c3

18 files changed

+127
-119
lines changed

sdk/tables/azure-data-tables/azure/data/tables/_authentication.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class AzureSigningError(ClientAuthenticationError):
4949
class SharedKeyCredentialPolicy(SansIOHTTPPolicy):
5050
def __init__(
5151
self, account_name, account_key, is_emulated=False
52-
): # pylint: disable=super-init-not-called
52+
):
5353
self.account_name = account_name
5454
self.account_key = account_key
5555
self.is_emulated = is_emulated

sdk/tables/azure-data-tables/azure/data/tables/_base_client.py

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -4,17 +4,8 @@
44
# license information.
55
# --------------------------------------------------------------------------
66

7-
from typing import ( # pylint: disable=unused-import
8-
Union,
9-
Optional,
10-
Any,
11-
Iterable,
12-
Dict,
13-
List,
14-
Type,
15-
Tuple,
16-
TYPE_CHECKING,
17-
)
7+
from typing import TYPE_CHECKING
8+
189
import logging
1910
from uuid import uuid4, UUID
2011
from datetime import datetime
@@ -65,6 +56,18 @@
6556
from ._models import BatchErrorException
6657
from ._sdk_moniker import SDK_MONIKER
6758

59+
if TYPE_CHECKING:
60+
from typing import ( # pylint: disable=ungrouped-imports
61+
Union,
62+
Optional,
63+
Any,
64+
Iterable,
65+
Dict,
66+
List,
67+
Type,
68+
Tuple,
69+
)
70+
6871
_LOGGER = logging.getLogger(__name__)
6972
_SERVICE_PARAMS = {
7073
"blob": {"primary": "BlobEndpoint", "secondary": "BlobSecondaryEndpoint"},
@@ -75,7 +78,7 @@
7578
}
7679

7780

78-
class StorageAccountHostsMixin(object): # pylint: disable=too-many-instance-attributes
81+
class StorageAccountHostsMixin(object):
7982
def __init__(
8083
self,
8184
parsed_url, # type: Any
@@ -261,7 +264,7 @@ def _configure_credential(self, credential):
261264
elif credential is not None:
262265
raise TypeError("Unsupported credential: {}".format(credential))
263266

264-
def _batch_send( # pylint: disable=inconsistent-return-statements
267+
def _batch_send(
265268
self,
266269
entities, # type: List[TableEntity]
267270
*reqs, # type: List[HttpRequest]
@@ -292,7 +295,7 @@ def _batch_send( # pylint: disable=inconsistent-return-statements
292295
boundary="batch_{}".format(uuid4()),
293296
)
294297

295-
pipeline_response = self._client._client._pipeline.run(request, **kwargs) # pylint:disable=protected-access
298+
pipeline_response = self._client._client._pipeline.run(request, **kwargs) # pylint: disable=protected-access
296299
response = pipeline_response.http_response
297300

298301
if response.status_code == 403:
@@ -328,10 +331,10 @@ def _batch_send( # pylint: disable=inconsistent-return-statements
328331
)
329332
return transaction_result
330333

331-
def _parameter_filter_substitution( # pylint: disable = R0201
334+
def _parameter_filter_substitution( # pylint: disable=no-self-use
332335
self,
333336
parameters, # type: dict[str,str]
334-
filter # type: str # pylint: disable = W0622
337+
filter # type: str pylint: disable=redefined-builtin
335338
):
336339
"""Replace user defined parameter in filter
337340
:param parameters: User defined parameters
@@ -354,7 +357,7 @@ def _parameter_filter_substitution( # pylint: disable = R0201
354357
filter_strings[index] = "'{}'".format(val)
355358
return ' '.join(filter_strings)
356359

357-
return filter # pylint: disable = W0622
360+
return filter
358361

359362

360363
class TransportWrapper(HttpTransport):
@@ -378,7 +381,7 @@ def close(self):
378381
def __enter__(self):
379382
pass
380383

381-
def __exit__(self, *args): # pylint: disable=arguments-differ
384+
def __exit__(self, *args):
382385
pass
383386

384387

sdk/tables/azure-data-tables/azure/data/tables/_deserialize.py

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,8 @@
33
# Licensed under the MIT License. See License.txt in the project root for
44
# license information.
55
# --------------------------------------------------------------------------
6-
# pylint: disable=unused-argument
7-
from typing import ( # pylint: disable=unused-import
8-
Union,
9-
Optional,
10-
Any,
11-
Iterable,
12-
Dict,
13-
List,
14-
Type,
15-
Tuple,
16-
TYPE_CHECKING,
17-
)
6+
7+
from typing import TYPE_CHECKING
188
from uuid import UUID
199
import logging
2010
import datetime
@@ -37,6 +27,18 @@
3727
except ImportError:
3828
from urllib2 import quote # type: ignore
3929

30+
if TYPE_CHECKING:
31+
from typing import ( # pylint: disable=ungrouped-imports
32+
Union,
33+
Optional,
34+
Any,
35+
Iterable,
36+
Dict,
37+
List,
38+
Type,
39+
Tuple,
40+
)
41+
4042

4143
def url_quote(url):
4244
return quote(url)
@@ -81,7 +83,7 @@ def _from_entity_int64(value):
8183
zero = datetime.timedelta(0) # same as 00:00
8284

8385

84-
class Timezone(datetime.tzinfo): # pylint: disable : W0223
86+
class Timezone(datetime.tzinfo):
8587
def utcoffset(self, dt):
8688
return zero
8789

@@ -183,18 +185,18 @@ def _convert_to_entity(entry_element):
183185
mtype = edmtypes.get(name)
184186

185187
# Add type for Int32
186-
if type(value) is int and mtype is None: # pylint:disable=C0123
188+
if isinstance(value, int) and mtype is None:
187189
mtype = EdmType.INT32
188190

189191
if value >= 2 ** 31 or value < (-(2 ** 31)):
190192
mtype = EdmType.INT64
191193

192194
# Add type for String
193195
try:
194-
if type(value) is unicode and mtype is None: # pylint:disable=C0123
196+
if isinstance(value, unicode) and mtype is None:
195197
mtype = EdmType.STRING
196198
except NameError:
197-
if type(value) is str and mtype is None: # pylint:disable=C0123
199+
if isinstance(value, str) and mtype is None:
198200
mtype = EdmType.STRING
199201

200202
# no type info, property should parse automatically
@@ -216,7 +218,7 @@ def _convert_to_entity(entry_element):
216218
etag = "W/\"datetime'" + url_quote(timestamp) + "'\""
217219
entity["etag"] = etag
218220

219-
entity._set_metadata() # pylint: disable = W0212
221+
entity._set_metadata() # pylint: disable=protected-access
220222
return entity
221223

222224

sdk/tables/azure-data-tables/azure/data/tables/_entity.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,14 @@ class TableEntity(dict):
2424

2525
def _set_metadata(self):
2626
if "Timestamp" in self.keys():
27-
self._metadata = { # pylint:disable=W0201
27+
self._metadata = { # pylint: disable=attribute-defined-outside-init
2828
"etag": self.pop("etag"),
2929
"timestamp": self.pop("Timestamp"),
3030
}
3131
else:
32-
self._metadata = {"etag": self.pop("etag")} # pylint:disable=W0201
32+
self._metadata = {"etag": self.pop("etag")} # pylint: disable=attribute-defined-outside-init
3333

34-
def metadata(self, **kwargs): # pylint: disable = W0613
34+
def metadata(self):
3535
# type: (...) -> Dict[str,Any]
3636
"""Resets metadata to be a part of the entity
3737
:return Dict of entity metadata
@@ -83,7 +83,7 @@ class EntityProperty(object):
8383
def __init__(
8484
self,
8585
value=None, # type: Any
86-
type=None, # type: Union[str,EdmType] # pylint:disable=W0622
86+
type=None, # type: Union[str,EdmType] pylint: disable=redefined-builtin
8787
):
8888
"""
8989
Represents an Azure Table. Returned by list_tables.

sdk/tables/azure-data-tables/azure/data/tables/_error.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,17 +55,17 @@ def _validate_not_none(param_name, param):
5555

5656
def _wrap_exception(ex, desired_type):
5757
msg = ""
58-
if len(ex.args) > 0: # pylint: disable=C1801
58+
if len(ex.args) > 0:
5959
msg = ex.args[0]
60-
if version_info >= (3,): # pylint: disable=R1705
60+
if version_info >= (3,):
6161
# Automatic chaining in Python 3 means we keep the trace
6262
return desired_type(msg)
63-
else:
64-
# There isn't a good solution in 2 for keeping the stack trace
65-
# in general, or that will not result in an error in 3
66-
# However, we can keep the previous error type and message
67-
# TODO: In the future we will log the trace
68-
return desired_type("{}: {}".format(ex.__class__.__name__, msg))
63+
64+
# There isn't a good solution in 2 for keeping the stack trace
65+
# in general, or that will not result in an error in 3
66+
# However, we can keep the previous error type and message
67+
# TODO: In the future we will log the trace
68+
return desired_type("{}: {}".format(ex.__class__.__name__, msg))
6969

7070

7171
def _validate_table_name(table_name):

sdk/tables/azure-data-tables/azure/data/tables/_models.py

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ class TableServiceStats(GenTableServiceStats):
3030
:type geo_replication: ~azure.data.tables.models.GeoReplication
3131
"""
3232

33-
def __init__(self, geo_replication=None, **kwargs): # pylint:disable=W0231
33+
def __init__( # pylint: disable=super-init-not-called
34+
self, geo_replication=None, **kwargs
35+
):
3436
self.geo_replication = geo_replication
3537

3638

@@ -77,9 +79,9 @@ class AccessPolicy(GenAccessPolicy):
7779
:type start: ~datetime.datetime or str
7880
"""
7981

80-
def __init__(
82+
def __init__( # pylint: disable=super-init-not-called
8183
self, permission=None, expiry=None, start=None, **kwargs
82-
): # pylint:disable=W0231
84+
):
8385
self.start = start
8486
self.expiry = expiry
8587
self.permission = permission
@@ -98,7 +100,7 @@ class TableAnalyticsLogging(GeneratedLogging):
98100
The retention policy for the metrics.
99101
"""
100102

101-
def __init__( # pylint:disable=W0231
103+
def __init__( # pylint: disable=super-init-not-called
102104
self, **kwargs # type: Any
103105
):
104106
# type: (...)-> None
@@ -118,7 +120,7 @@ def _from_generated(cls, generated):
118120
delete=generated.delete,
119121
read=generated.read,
120122
write=generated.write,
121-
retention_policy=RetentionPolicy._from_generated( # pylint:disable=protected-access
123+
retention_policy=RetentionPolicy._from_generated( # pylint: disable=protected-access
122124
generated.retention_policy
123125
)
124126
)
@@ -137,7 +139,7 @@ class Metrics(GeneratedMetrics):
137139
The retention policy for the metrics.
138140
"""
139141

140-
def __init__( # pylint:disable=super-init-not-called
142+
def __init__( # pylint: disable=super-init-not-called
141143
self,
142144
**kwargs # type: Any
143145
):
@@ -166,7 +168,7 @@ def _from_generated(cls, generated):
166168

167169

168170
class RetentionPolicy(GeneratedRetentionPolicy):
169-
def __init__( # pylint:disable=W0231
171+
def __init__( # pylint: disable=super-init-not-called
170172
self,
171173
enabled=False, # type: bool
172174
days=None, # type: int
@@ -191,7 +193,7 @@ def __init__( # pylint:disable=W0231
191193
raise ValueError("If policy is enabled, 'days' must be specified.")
192194

193195
@classmethod
194-
def _from_generated(cls, generated, **kwargs): # pylint:disable=W0613
196+
def _from_generated(cls, generated, **kwargs): # pylint: disable=unused-argument
195197
# type: (...) -> cls
196198
"""The retention policy which determines how long the associated data should
197199
persist.
@@ -239,7 +241,7 @@ class CorsRule(GeneratedCorsRule):
239241
headers. Each header can be up to 256 characters.
240242
"""
241243

242-
def __init__( # pylint:disable=W0231
244+
def __init__( # pylint: disable=super-init-not-called
243245
self,
244246
allowed_origins, # type: list[str]
245247
allowed_methods, # type: list[str]
@@ -307,7 +309,7 @@ def _get_next_cb(self, continuation_token, **kwargs):
307309
def _extract_data_cb(self, get_next_return):
308310
self.location_mode, self._response, self._headers = get_next_return
309311
props_list = [
310-
TableItem._from_generated(t, **self._headers) for t in self._response.value # pylint:disable=protected-access
312+
TableItem._from_generated(t, **self._headers) for t in self._response.value # pylint: disable=protected-access
311313
]
312314
return self._headers[NEXT_TABLE_NAME] or None, props_list
313315

@@ -416,7 +418,7 @@ def from_string(
416418
cls,
417419
permission, # type: str
418420
**kwargs
419-
): # pylint:disable=W0613
421+
):
420422
"""Create AccountSasPermissions from a string.
421423
422424
To specify read, write, delete, etc. permissions you need only to
@@ -490,7 +492,7 @@ def __init__(self, table_name, **kwargs):
490492
self.date = kwargs.get("date") or kwargs.get("Date")
491493

492494
@classmethod
493-
def _from_generated(cls, generated, **kwargs): # pylint:disable=W0613
495+
def _from_generated(cls, generated, **kwargs):
494496
# type: (obj, **Any) -> cls
495497
return cls(generated.table_name, **kwargs)
496498

@@ -670,7 +672,7 @@ class AccountSasPermissions(object):
670672
Valid for the following Object resource type only: queue messages.
671673
"""
672674

673-
def __init__(self, **kwargs): # pylint: disable=redefined-builtin
675+
def __init__(self, **kwargs):
674676
self.read = kwargs.pop("read", None)
675677
self.write = kwargs.pop("write", None)
676678
self.delete = kwargs.pop("delete", None)
@@ -694,7 +696,7 @@ def __str__(self):
694696
return self._str
695697

696698
@classmethod
697-
def from_string(cls, permission, **kwargs): # pylint:disable=W0613
699+
def from_string(cls, permission, **kwargs):
698700
"""Create AccountSasPermissions from a string.
699701
700702
To specify read, write, delete, etc. permissions you need only to

sdk/tables/azure-data-tables/azure/data/tables/_policies.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ def on_response(self, request, response):
279279

280280

281281
class StorageRequestHook(SansIOHTTPPolicy):
282-
def __init__(self, **kwargs): # pylint: disable=unused-argument
282+
def __init__(self, **kwargs):
283283
self._request_callback = kwargs.get("raw_request_hook")
284284
super(StorageRequestHook, self).__init__()
285285

@@ -293,7 +293,7 @@ def on_request(self, request):
293293

294294

295295
class StorageResponseHook(HTTPPolicy):
296-
def __init__(self, **kwargs): # pylint: disable=unused-argument
296+
def __init__(self, **kwargs):
297297
self._response_callback = kwargs.get("raw_response_hook")
298298
super(StorageResponseHook, self).__init__()
299299

@@ -485,7 +485,7 @@ def _set_next_host_location(self, settings, request): # pylint: disable=no-self
485485
def configure_retries(
486486
self, request
487487
): # pylint: disable=no-self-use, arguments-differ
488-
# type: (...)-> dict
488+
# type: (...) -> Dict[Any, Any]
489489
"""
490490
:param Any request:
491491
:param kwargs:
@@ -532,7 +532,7 @@ def sleep(self, settings, transport): # pylint: disable=arguments-differ
532532

533533
def increment(
534534
self, settings, request, response=None, error=None, **kwargs
535-
): # pylint:disable=unused-argument, arguments-differ
535+
): # pylint: disable=unused-argument, arguments-differ
536536
# type: (...)->None
537537
"""Increment the retry counters.
538538

0 commit comments

Comments
 (0)