Skip to content

Commit 2b2b8bf

Browse files
mbogosianposita
authored andcommitted
Formatting cleanup
1 parent 77d20cf commit 2b2b8bf

10 files changed

+58
-41
lines changed

.pylintrc

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[MESSAGES CONTROL]
2-
disable=C,R,fixme,locally-disabled,protected-access,useless-else-on-loop
2+
disable=C,R,file-ignored,fixme,locally-disabled,protected-access,useless-else-on-loop
33
enable=useless-suppression
44

55
[REPORTS]

dropbox/babel_validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def validate(self, val):
357357
raise ValidationError('expected timestamp, got %s'
358358
% generic_type_name(val))
359359
elif val.tzinfo is not None and \
360-
val.tzinfo.utcoffset(val).total_seconds() != 0:
360+
val.tzinfo.utcoffset(val).total_seconds() != 0:
361361
raise ValidationError('timestamp should have either a UTC '
362362
'timezone or none set at all')
363363
return val

dropbox/client.py

+15-11
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ def __init__(self, oauth2_access_token, locale=None, rest_client=None):
7676
'You are using a deprecated client. Please use the new v2 client '
7777
'located at dropbox.Dropbox.', DeprecationWarning, stacklevel=2)
7878

79-
if rest_client is None: rest_client = RESTClient
79+
if rest_client is None:
80+
rest_client = RESTClient
8081
if isinstance(oauth2_access_token, basestring):
8182
if not _OAUTH2_ACCESS_TOKEN_PATTERN.match(oauth2_access_token):
8283
raise ValueError("invalid format for oauth2_access_token: %r"
@@ -118,7 +119,7 @@ def request(self, target, params=None, method='POST',
118119
A tuple of ``(url, params, headers)`` that should be used to make the request.
119120
OAuth will be added as needed within these fields.
120121
"""
121-
assert method in ['GET','POST', 'PUT'], "Only 'GET', 'POST', and 'PUT' are allowed."
122+
assert method in ['GET', 'POST', 'PUT'], "Only 'GET', 'POST', and 'PUT' are allowed."
122123
assert not (content_server and notification_server), \
123124
"Cannot construct request simultaneously for content and notification servers."
124125

@@ -219,7 +220,7 @@ def get_chunked_uploader(self, file_obj, length):
219220
return ChunkedUploader(self, file_obj, length)
220221

221222
def upload_chunk(self, file_obj, length=None, offset=0, # pylint: disable=unused-argument
222-
upload_id=None):
223+
upload_id=None):
223224
"""Uploads a single chunk of data from a string or file-like object. The majority of users
224225
should use the :class:`ChunkedUploader` object, which provides a simpler interface to the
225226
chunked_upload API endpoint.
@@ -486,7 +487,8 @@ def __parse_metadata_as_dict(dropbox_raw_response):
486487
metadata = json.loads(header_val)
487488
except ValueError:
488489
raise ErrorResponse(dropbox_raw_response, '')
489-
if not metadata: raise ErrorResponse(dropbox_raw_response, '')
490+
if not metadata:
491+
raise ErrorResponse(dropbox_raw_response, '')
490492
return metadata
491493

492494
def delta(self, cursor=None, path_prefix=None, include_media_info=False):
@@ -930,12 +932,11 @@ def thumbnail(self, from_path, size='m', format='JPEG'): # pylint: disable=rede
930932
- 415: Image is invalid and cannot be thumbnailed.
931933
"""
932934
assert format in ['JPEG', 'PNG'], \
933-
"expected a thumbnail format of 'JPEG' or 'PNG', got %s" % format
935+
"expected a thumbnail format of 'JPEG' or 'PNG', got %s" % format
934936

935937
path = "/thumbnails/%s%s" % (self.session.root, format_path(from_path))
936-
937938
url, _, headers = self.request(path, {'size': size, 'format': format},
938-
method='GET', content_server=True)
939+
method='GET', content_server=True)
939940
return self.rest_client.request("GET", url, headers=headers, raw_response=True)
940941

941942
def thumbnail_and_metadata(self, from_path, size='m', format='JPEG'): # noqa: E501; pylint: disable=redefined-builtin
@@ -1373,7 +1374,8 @@ def __init__(self, consumer_key, consumer_secret, locale=None, rest_client=None)
13731374
Optional :class:`dropbox.rest.RESTClient`-like object to use for making
13741375
requests.
13751376
"""
1376-
if rest_client is None: rest_client = RESTClient
1377+
if rest_client is None:
1378+
rest_client = RESTClient
13771379
super(DropboxOAuth2FlowNoRedirect, self).__init__(consumer_key, consumer_secret,
13781380
locale, rest_client)
13791381

@@ -1480,7 +1482,8 @@ def __init__(self, consumer_key, consumer_secret, redirect_uri, session,
14801482
Optional :class:`dropbox.rest.RESTClient`-like object to use for making
14811483
requests.
14821484
"""
1483-
if rest_client is None: rest_client = RESTClient
1485+
if rest_client is None:
1486+
rest_client = RESTClient
14841487
super(DropboxOAuth2Flow, self).__init__(consumer_key, consumer_secret, locale, rest_client)
14851488
self.redirect_uri = redirect_uri
14861489
self.session = session
@@ -1578,7 +1581,7 @@ def finish(self, query_params):
15781581
url_state = None
15791582
else:
15801583
given_csrf_token = state[0:split_pos]
1581-
url_state = state[split_pos+1:]
1584+
url_state = state[split_pos + 1:]
15821585

15831586
if not _safe_equals(csrf_token_from_session, given_csrf_token):
15841587
raise self.CsrfException("expected %r, got %r" % (csrf_token_from_session,
@@ -1654,7 +1657,8 @@ class ProviderException(Exception):
16541657

16551658

16561659
def _safe_equals(a, b):
1657-
if len(a) != len(b): return False
1660+
if len(a) != len(b):
1661+
return False
16581662
res = 0
16591663
for ca, cb in zip(a, b):
16601664
res |= ord(ca) ^ ord(cb)

dropbox/oauth.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ def finish(self, query_params):
391391
url_state = None
392392
else:
393393
given_csrf_token = state[0:split_pos]
394-
url_state = state[split_pos+1:]
394+
url_state = state[split_pos + 1:]
395395

396396
if not _safe_equals(csrf_token_from_session, given_csrf_token):
397397
raise CsrfException('expected %r, got %r' %
@@ -475,7 +475,8 @@ class ProviderException(Exception):
475475

476476

477477
def _safe_equals(a, b):
478-
if len(a) != len(b): return False
478+
if len(a) != len(b):
479+
return False
479480
res = 0
480481
for ca, cb in zip(a, b):
481482
res |= ord(ca) ^ ord(cb)

dropbox/session.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -309,9 +309,8 @@ def build_access_headers(self, params=None, request_token=None):
309309
@classmethod
310310
def _oauth_sign_request(cls, params, consumer_pair, token_pair):
311311
params.update({'oauth_signature_method': 'PLAINTEXT',
312-
'oauth_signature': ('%s&%s' % (consumer_pair.secret, token_pair.secret)
313-
if token_pair is not None else
314-
'%s&' % (consumer_pair.secret,))})
312+
'oauth_signature': ('%s&%s' % (consumer_pair.secret, token_pair.secret)
313+
if token_pair is not None else '%s&' % (consumer_pair.secret,))})
315314

316315
@classmethod
317316
def _generate_oauth_timestamp(cls):

dropbox/stone_serializers.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ def encode_primitive(self, validator, value):
242242
else:
243243
return base64.b64encode(value).decode('ascii')
244244
elif isinstance(validator, bv.Integer) \
245-
and isinstance(value, bool):
245+
and isinstance(value, bool):
246246
# bool is sub-class of int so it passes Integer validation,
247247
# but we want the bool to be encoded as ``0`` or ``1``, rather
248248
# than ``False`` or ``True``, respectively
@@ -302,8 +302,8 @@ def encode_union(self, validator, value):
302302

303303
field_validator = validator.definition._tagmap[value._tag]
304304
is_none = isinstance(field_validator, bv.Void) \
305-
or (isinstance(field_validator, bv.Nullable)
306-
and value._value is None)
305+
or (isinstance(field_validator, bv.Nullable)
306+
and value._value is None)
307307

308308
def encode_sub(sub_validator, sub_value, parent_tag):
309309
try:
@@ -361,7 +361,8 @@ def encode(self, validator, value):
361361
# functions.
362362

363363
def json_encode(data_type, obj, alias_validators=None, old_style=False):
364-
"""Encodes an object into JSON based on its type.
364+
"""
365+
Encodes an object into JSON based on its type.
365366
366367
Args:
367368
data_type (Validator): Validator for obj.

dropbox/stone_validators.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ def validate(self, val):
363363
raise ValidationError('expected timestamp, got %s'
364364
% generic_type_name(val))
365365
elif val.tzinfo is not None and \
366-
val.tzinfo.utcoffset(val).total_seconds() != 0:
366+
val.tzinfo.utcoffset(val).total_seconds() != 0:
367367
raise ValidationError('timestamp should have either a UTC '
368368
'timezone or none set at all')
369369
return val

test/test_dropbox.py

+27-16
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,9 @@ def test_bad_upload_types(self, dbx):
115115
def test_team(self, dbxt):
116116
dbxt.team_groups_list()
117117
r = dbxt.team_members_list()
118-
if r.members: # pylint: disable=no-member
118+
if r.members:
119119
# Only test assuming a member if there is a member
120-
team_member_id = r.members[0].profile.team_member_id # pylint: disable=no-member
120+
team_member_id = r.members[0].profile.team_member_id
121121
dbxt.as_user(team_member_id).files_list_folder('')
122122

123123

@@ -190,7 +190,7 @@ def test_account_info(self, dbx_client):
190190
@dbx_v1_client_from_env_with_test_dir
191191
def test_put_file(self, dbx_client, test_dir):
192192
"""Tests if put_file returns the expected metadata"""
193-
def test_put(file, path): # pylint: disable=redefined-builtin,useless-suppression
193+
def test_put(file, path): # pylint: disable=redefined-builtin
194194
file_path = posixpath.join(test_dir, path)
195195
f = open(file, "rb")
196196
metadata = dbx_client.put_file(file_path, f)
@@ -218,7 +218,7 @@ def test_put_file_overwrite(self, dbx_client, test_dir):
218218
@dbx_v1_client_from_env_with_test_dir
219219
def test_get_file(self, dbx_client, test_dir):
220220
"""Tests if storing and retrieving a file returns the same file"""
221-
def test_get(file, path): # pylint: disable=redefined-builtin,useless-suppression
221+
def test_get(file, path): # pylint: disable=redefined-builtin
222222
file_path = posixpath.join(test_dir, path)
223223
self.upload_file(dbx_client, file, file_path)
224224
downloaded = dbx_client.get_file(file_path).read()
@@ -232,7 +232,7 @@ def test_get(file, path): # pylint: disable=redefined-builtin,useless-suppressi
232232
@dbx_v1_client_from_env_with_test_dir
233233
def test_get_partial_file(self, dbx_client, test_dir):
234234
"""Tests if storing a file and retrieving part of it returns the correct part"""
235-
def test_get(file, path, start_frac, download_frac): # noqa: E501; pylint: disable=redefined-builtin,useless-suppression
235+
def test_get(file, path, start_frac, download_frac): # noqa: E501; pylint: disable=redefined-builtin
236236
file_path = posixpath.join(test_dir, path)
237237
self.upload_file(dbx_client, file, file_path)
238238
local = open(file, "rb").read()
@@ -241,7 +241,7 @@ def test_get(file, path, start_frac, download_frac): # noqa: E501; pylint: disa
241241
download_start = int(start_frac * local_len) if start_frac is not None else None
242242
download_length = int(download_frac * local_len) if download_frac is not None else None
243243
downloaded = dbx_client.get_file(file_path, start=download_start,
244-
length=download_length).read()
244+
length=download_length).read()
245245

246246
local_file = open(file, "rb")
247247
if download_start:
@@ -489,13 +489,20 @@ def test_chunked_upload2(self, dbx_client, test_dir):
489489
self.assertEqual(new_offset, chunk_size)
490490
self.assertIsNotNone(upload_id)
491491

492-
new_offset, upload_id2 = dbx_client.upload_chunk(BytesIO(random_data2), 0,
493-
new_offset, upload_id)
492+
new_offset, upload_id2 = dbx_client.upload_chunk(
493+
BytesIO(random_data2),
494+
0,
495+
new_offset,
496+
upload_id,
497+
)
494498
self.assertEqual(new_offset, chunk_size * 2)
495499
self.assertEqual(upload_id2, upload_id)
496500

497-
metadata = dbx_client.commit_chunked_upload('/auto' + target_path, upload_id,
498-
overwrite=True)
501+
metadata = dbx_client.commit_chunked_upload(
502+
'/auto' + target_path,
503+
upload_id,
504+
overwrite=True,
505+
)
499506
self.dict_has(metadata, bytes=chunk_size * 2, path=target_path)
500507

501508
downloaded = dbx_client.get_file(target_path).read()
@@ -544,12 +551,14 @@ def test_delta(self, dbx_client, test_dir):
544551
cursor = None
545552
while True:
546553
r = dbx_client.delta(cursor)
547-
if r['reset']: entries = set()
554+
if r['reset']:
555+
entries = set()
548556
for path_lc, md in r['entries']:
549-
if path_lc.startswith(prefix_lc+'/') or path_lc == prefix_lc:
557+
if path_lc.startswith(prefix_lc + '/') or path_lc == prefix_lc:
550558
assert md is not None, "we should never get deletes under 'prefix'"
551559
entries.add(path_lc)
552-
if not r['has_more']: break
560+
if not r['has_more']:
561+
break
553562
cursor = r['cursor']
554563

555564
self.assertEqual(expected, entries)
@@ -560,12 +569,14 @@ def test_delta(self, dbx_client, test_dir):
560569
cursor = None
561570
while True:
562571
r = dbx_client.delta(cursor, path_prefix=c)
563-
if r['reset']: entries = set()
572+
if r['reset']:
573+
entries = set()
564574
for path_lc, md in r['entries']:
565-
assert path_lc.startswith(c_lc+'/') or path_lc == c_lc
575+
assert path_lc.startswith(c_lc + '/') or path_lc == c_lc
566576
assert md is not None, "we should never get deletes"
567577
entries.add(path_lc)
568-
if not r['has_more']: break
578+
if not r['has_more']:
579+
break
569580
cursor = r['cursor']
570581

571582
self.assertEqual(expected, entries)

tox.ini

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ pypy3 = lint
1616

1717
[flake8]
1818

19-
ignore = E127,E128,E226,E231,E301,E302,E305,E402,E701,W503
19+
# See <https://pycodestyle.readthedocs.io/en/latest/intro.html#error-codes>
20+
ignore = E128,E301,E302,E305,E402,W503
2021
max-line-length = 100
2122

2223

0 commit comments

Comments
 (0)