Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 0c88da4

Browse filesBrowse files
committed
Updated source for Pylint 1.5.
Pylint 1.5 brought with it much more than pylint.extensions.check_docs The changes for this PR are - checking import order - checking self._foo is set in __init__ - complaining about methods that don't use self - complaining about not calling super().__init__ (for the virtual base class we used) - complaining about not (self == other) in __ne__, suggested (self != other) instead - complaining about unit tests checking None result from methods which are known (by static analysis?) to return None - complaining about not over-riding virtual method in storage _PropertyMixin - aggressively checking `redefined-variable-type` when variables can be optionally float/int/Entity/Key/etc. - checking that GCloudError constructor is called correctly in unit tests - checking that subclass method overrides use the same arguments (this occurred in BigQuery test_job with _makeResource)
1 parent 6a9e9bc commit 0c88da4
Copy full SHA for 0c88da4

File tree

Expand file treeCollapse file tree

20 files changed

+66
-42
lines changed
Filter options
Expand file treeCollapse file tree

20 files changed

+66
-42
lines changed

‎gcloud/_helpers.py

Copy file name to clipboardExpand all lines: gcloud/_helpers.py
+7-10Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,20 @@
1919
import calendar
2020
import datetime
2121
import os
22-
import six
22+
from threading import local as Local
2323
import socket
2424

25-
try:
26-
from threading import local as Local
27-
except ImportError: # pragma: NO COVER (who doesn't have it?)
28-
class Local(object):
29-
"""Placeholder for non-threaded applications."""
30-
25+
import six
3126
from six.moves.http_client import HTTPConnection # pylint: disable=F0401
3227

28+
from gcloud.environment_vars import PROJECT
29+
30+
# pylint: disable=wrong-import-position
3331
try:
3432
from google.appengine.api import app_identity
3533
except ImportError:
3634
app_identity = None
37-
38-
from gcloud.environment_vars import PROJECT
35+
# pylint: enable=wrong-import-position
3936

4037

4138
_NOW = datetime.datetime.utcnow # To be replaced by tests.
@@ -297,7 +294,7 @@ def _to_bytes(value, encoding='ascii'):
297294

298295

299296
try:
300-
from pytz import UTC # pylint: disable=unused-import
297+
from pytz import UTC # pylint: disable=unused-import,wrong-import-position
301298
except ImportError:
302299
UTC = _UTC() # Singleton instance to be used throughout.
303300

‎gcloud/bigquery/dataset.py

Copy file name to clipboardExpand all lines: gcloud/bigquery/dataset.py
+5-1Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,13 @@ class Dataset(object):
6060
:param access_grants: roles granted to entities for this dataset
6161
"""
6262

63+
_access_grants = None
64+
6365
def __init__(self, name, client, access_grants=()):
6466
self.name = name
6567
self._client = client
6668
self._properties = {}
69+
# Let the @property do validation.
6770
self.access_grants = access_grants
6871

6972
@property
@@ -283,7 +286,8 @@ def _require_client(self, client):
283286
client = self._client
284287
return client
285288

286-
def _parse_access_grants(self, access):
289+
@staticmethod
290+
def _parse_access_grants(access):
287291
"""Parse a resource fragment into a set of access grants.
288292
289293
:type access: list of mappings

‎gcloud/bigquery/job.py

Copy file name to clipboardExpand all lines: gcloud/bigquery/job.py
+4Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,14 @@ class LoadTableFromStorageJob(_AsyncJob):
444444
:type schema: list of :class:`gcloud.bigquery.table.SchemaField`
445445
:param schema: The job's schema
446446
"""
447+
448+
_schema = None
449+
447450
def __init__(self, name, destination, source_uris, client, schema=()):
448451
super(LoadTableFromStorageJob, self).__init__(name, client)
449452
self.destination = destination
450453
self.source_uris = source_uris
454+
# Let the @property do validation.
451455
self.schema = schema
452456
self._configuration = _LoadConfiguration()
453457

‎gcloud/bigquery/table.py

Copy file name to clipboardExpand all lines: gcloud/bigquery/table.py
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ class Table(object):
7272
:param schema: The table's schema
7373
"""
7474

75+
_schema = None
76+
7577
def __init__(self, name, dataset, schema=()):
7678
self.name = name
7779
self._dataset = dataset
7880
self._properties = {}
81+
# Let the @property do validation.
7982
self.schema = schema
8083

8184
@property

‎gcloud/client.py

Copy file name to clipboardExpand all lines: gcloud/client.py
-3Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ class _ClientFactoryMixin(object):
3131
This class is virtual.
3232
"""
3333

34-
def __init__(self, *args, **kwargs):
35-
raise NotImplementedError('_ClientFactoryMixin is a virtual class')
36-
3734
@classmethod
3835
def from_service_account_json(cls, json_credentials_path, *args, **kwargs):
3936
"""Factory to retrieve JSON credentials while creating client.

‎gcloud/credentials.py

Copy file name to clipboardExpand all lines: gcloud/credentials.py
+7-6Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,21 +26,22 @@
2626
from oauth2client.client import _get_application_default_credential_from_file
2727
from oauth2client import crypt
2828
from oauth2client import service_account
29-
30-
try:
31-
from google.appengine.api import app_identity
32-
except ImportError:
33-
app_identity = None
34-
3529
try:
3630
from oauth2client.appengine import AppAssertionCredentials as _GAECreds
3731
except ImportError:
3832
class _GAECreds(object):
3933
"""Dummy class if not in App Engine environment."""
4034

35+
# pylint: disable=wrong-import-position
36+
try:
37+
from google.appengine.api import app_identity
38+
except ImportError:
39+
app_identity = None
40+
4141
from gcloud._helpers import UTC
4242
from gcloud._helpers import _NOW
4343
from gcloud._helpers import _microseconds_from_datetime
44+
# pylint: enable=wrong-import-position
4445

4546

4647
def get_credentials():

‎gcloud/datastore/entity.py

Copy file name to clipboardExpand all lines: gcloud/datastore/entity.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ def __eq__(self, other):
9292
:returns: True if the entities compare equal, else False.
9393
"""
9494
if not isinstance(other, Entity):
95-
return NotImplemented
95+
return False
9696

9797
return (self.key == other.key and
9898
super(Entity, self).__eq__(other))
@@ -106,7 +106,7 @@ def __ne__(self, other):
106106
:rtype: boolean
107107
:returns: False if the entities compare equal, else True.
108108
"""
109-
return not self == other
109+
return not self.__eq__(other)
110110

111111
@property
112112
def kind(self):

‎gcloud/datastore/key.py

Copy file name to clipboardExpand all lines: gcloud/datastore/key.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ def __eq__(self, other):
7979
:returns: True if the keys compare equal, else False.
8080
"""
8181
if not isinstance(other, Key):
82-
return NotImplemented
82+
return False
8383

8484
if self.is_partial or other.is_partial:
8585
return False
@@ -99,7 +99,7 @@ def __ne__(self, other):
9999
:rtype: boolean
100100
:returns: False if the keys compare equal, else True.
101101
"""
102-
return not self == other
102+
return not self.__eq__(other)
103103

104104
def __hash__(self):
105105
"""Hash a keys for use in a dictionary lookp.

‎gcloud/datastore/test_client.py

Copy file name to clipboardExpand all lines: gcloud/datastore/test_client.py
+1Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -677,6 +677,7 @@ def test_delete_multi_no_keys(self):
677677
client = self._makeOne(credentials=creds)
678678
result = client.delete_multi([])
679679
self.assertEqual(result, None)
680+
self.assertEqual(len(client.connection._commit_cw), 0)
680681

681682
def test_delete_multi_no_batch(self):
682683
from gcloud.datastore.test_batch import _CommitResult

‎gcloud/search/document.py

Copy file name to clipboardExpand all lines: gcloud/search/document.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,8 @@ def from_api_repr(cls, resource, index):
182182
document._parse_fields_resource(resource)
183183
return document
184184

185-
def _parse_value_resource(self, resource):
185+
@staticmethod
186+
def _parse_value_resource(resource):
186187
"""Helper for _parse_fields_resource"""
187188
if 'stringValue' in resource:
188189
string_format = resource.get('stringFormat')
@@ -245,7 +246,8 @@ def _require_client(self, client):
245246
client = self.index._client
246247
return client
247248

248-
def _build_value_resource(self, value):
249+
@staticmethod
250+
def _build_value_resource(value):
249251
"""Helper for _build_fields_resource"""
250252
result = {}
251253
if value.value_type == 'string':

‎gcloud/storage/_helpers.py

Copy file name to clipboardExpand all lines: gcloud/storage/_helpers.py
+2-1Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@
1717
These are *not* part of the API.
1818
"""
1919

20-
from Crypto.Hash import MD5
2120
import base64
2221

22+
from Crypto.Hash import MD5
23+
2324

2425
class _PropertyMixin(object):
2526
"""Abstract mixin for cloud storage classes with associated propertties.

‎gcloud/storage/batch.py

Copy file name to clipboardExpand all lines: gcloud/storage/batch.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,10 @@
2020
from email.mime.application import MIMEApplication
2121
from email.mime.multipart import MIMEMultipart
2222
from email.parser import Parser
23-
import httplib2
2423
import io
2524
import json
2625

26+
import httplib2
2727
import six
2828

2929
from gcloud.exceptions import make_exception

‎gcloud/storage/test__helpers.py

Copy file name to clipboardExpand all lines: gcloud/storage/test__helpers.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def _derivedClass(self, path=None):
2828

2929
class Derived(self._getTargetClass()):
3030

31+
client = None
32+
3133
@property
3234
def path(self):
3335
return path

‎gcloud/streaming/transfer.py

Copy file name to clipboardExpand all lines: gcloud/streaming/transfer.py
+10-4Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ class _Transfer(object):
5252
:type num_retries: integer
5353
:param num_retries: how many retries should the transfer attempt
5454
"""
55+
56+
_num_retries = None
57+
5558
def __init__(self, stream, close_stream=False,
5659
chunksize=_DEFAULT_CHUNKSIZE, auto_transfer=True,
5760
http=None, num_retries=5):
@@ -61,7 +64,7 @@ def __init__(self, stream, close_stream=False,
6164
self._stream = stream
6265
self._url = None
6366

64-
# Let the @property do validation
67+
# Let the @property do validation.
6568
self.num_retries = num_retries
6669

6770
self.auto_transfer = auto_transfer
@@ -385,7 +388,8 @@ def _normalize_start_end(self, start, end=None):
385388
start = max(0, start + self.total_size)
386389
return start, self.total_size - 1
387390

388-
def _set_range_header(self, request, start, end=None):
391+
@staticmethod
392+
def _set_range_header(request, start, end=None):
389393
"""Update the 'Range' header in a request to match a byte range.
390394
391395
:type request: :class:`gcloud.streaming.http_wrapper.Request`
@@ -915,7 +919,8 @@ def refresh_upload_state(self):
915919
else:
916920
raise HttpError.from_response(refresh_response)
917921

918-
def _get_range_header(self, response):
922+
@staticmethod
923+
def _get_range_header(response):
919924
"""Return a 'Range' header from a response.
920925
921926
:type response: :class:`gcloud.streaming.http_wrapper.Response`
@@ -975,7 +980,8 @@ def initialize_upload(self, http_request, http):
975980
else:
976981
return http_response
977982

978-
def _last_byte(self, range_header):
983+
@staticmethod
984+
def _last_byte(range_header):
979985
"""Parse the last byte from a 'Range' header.
980986
981987
:type range_header: string

‎gcloud/test_client.py

Copy file name to clipboardExpand all lines: gcloud/test_client.py
+2-4Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ def _getTargetClass(self):
2121
from gcloud.client import _ClientFactoryMixin
2222
return _ClientFactoryMixin
2323

24-
def _makeOne(self, *args, **kw):
25-
return self._getTargetClass()(*args, **kw)
26-
2724
def test_virtual(self):
28-
self.assertRaises(NotImplementedError, self._makeOne)
25+
klass = self._getTargetClass()
26+
self.assertFalse('__init__' in klass.__dict__)
2927

3028

3129
class TestClient(unittest2.TestCase):

‎gcloud/test_exceptions.py

Copy file name to clipboardExpand all lines: gcloud/test_exceptions.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ def _getTargetClass(self):
2121
from gcloud.exceptions import GCloudError
2222
return GCloudError
2323

24-
def _makeOne(self, *args):
25-
return self._getTargetClass()(*args)
24+
def _makeOne(self, message, errors=()):
25+
return self._getTargetClass()(message, errors=errors)
2626

2727
def test_ctor_defaults(self):
2828
e = self._makeOne('Testing')

‎pylintrc_default

Copy file name to clipboardExpand all lines: pylintrc_default
+6Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,11 @@ load-plugins=pylint.extensions.check_docs
8080
# @_lazy_property_deco
8181
# def dataset_id():
8282
# ...
83+
# - redefined-variable-type: This error is overzealous and complains at e.g.
84+
# if some_prop:
85+
# return int(value)
86+
# else:
87+
# return float(value)
8388
disable =
8489
maybe-no-member,
8590
no-member,
@@ -88,6 +93,7 @@ disable =
8893
similarities,
8994
star-args,
9095
method-hidden,
96+
redefined-variable-type,
9197

9298

9399
[REPORTS]

‎run_pylint.py

Copy file name to clipboardExpand all lines: run_pylint.py
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@
5151
'too-many-locals',
5252
'too-many-public-methods',
5353
'unbalanced-tuple-unpacking',
54+
'arguments-differ',
55+
'assignment-from-no-return',
5456
]
5557
TEST_RC_ADDITIONS = {
5658
'MESSAGES CONTROL': {

‎system_tests/storage.py

Copy file name to clipboardExpand all lines: system_tests/storage.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,12 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import httplib2
1615
import os
17-
import six
1816
import tempfile
1917
import time
18+
19+
import httplib2
20+
import six
2021
import unittest2
2122

2223
from gcloud import _helpers

‎tox.ini

Copy file name to clipboardExpand all lines: tox.ini
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,7 @@ commands =
7575
python run_pylint.py
7676
deps =
7777
pep8
78-
-ehg+https://bitbucket.org/logilab/pylint@33e334be064c#egg=pylint
79-
logilab-common<=0.63.0 # Hack for pylint upstream
78+
pylint
8079
unittest2
8180
protobuf==3.0.0-alpha-1
8281
passenv = {[testenv:system-tests]passenv}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.