Skip to content

Commit 0f8bd8e

Browse files
committed
Merge pull request #1248 from dhermes/update-for-new-pylint
Updated source for Pylint 1.5.
2 parents 6a9e9bc + 0c88da4 commit 0f8bd8e

File tree

20 files changed

+66
-42
lines changed

20 files changed

+66
-42
lines changed

gcloud/_helpers.py

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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

Lines 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':

0 commit comments

Comments
 (0)