Skip to content

Commit c5922c6

Browse files
author
Jon Wayne Parrott
authored
Re-enable flake8 for core package and tests (#3664)
1 parent 1598d5d commit c5922c6

File tree

10 files changed

+26
-25
lines changed

10 files changed

+26
-25
lines changed

core/.flake8

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
[flake8]
22
import-order-style=google
3+
# Note: this forces all google imports to be in the third group. See
4+
# https://github.com/PyCQA/flake8-import-order/issues/111
5+
application-import-names=google
36
exclude =
47
__pycache__,
58
.git,

core/google/cloud/_helpers.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,21 +25,21 @@
2525
import re
2626
from threading import local as Local
2727

28+
import google_auth_httplib2
29+
import httplib2
30+
import six
31+
from six.moves import http_client
32+
2833
import google.auth
2934
from google.protobuf import duration_pb2
3035
from google.protobuf import timestamp_pb2
31-
import google_auth_httplib2
3236

3337
try:
3438
import grpc
3539
import google.auth.transport.grpc
3640
except ImportError: # pragma: NO COVER
3741
grpc = None
3842

39-
import httplib2
40-
import six
41-
from six.moves import http_client
42-
4343

4444
_NOW = datetime.datetime.utcnow # To be replaced by tests.
4545
_RFC3339_MICROS = '%Y-%m-%dT%H:%M:%S.%fZ'

core/google/cloud/_http.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616

1717
import json
1818
import platform
19-
from pkg_resources import get_distribution
2019

20+
from pkg_resources import get_distribution
2121
import six
2222
from six.moves.urllib.parse import urlencode
2323

core/google/cloud/client.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
import json
1919
from pickle import PicklingError
2020

21-
import google.auth.credentials
22-
from google.oauth2 import service_account
2321
import google_auth_httplib2
2422
import six
2523

24+
import google.auth.credentials
2625
from google.cloud._helpers import _determine_default_project
2726
from google.cloud.credentials import get_credentials
27+
from google.oauth2 import service_account
2828

2929

3030
_GOOGLE_AUTH_CREDENTIALS_HELP = (

core/google/cloud/credentials.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,15 @@
1616

1717
import base64
1818
import datetime
19+
1920
import six
2021
from six.moves.urllib.parse import urlencode
2122

2223
import google.auth
2324
import google.auth.credentials
24-
25-
from google.cloud._helpers import UTC
26-
from google.cloud._helpers import _NOW
2725
from google.cloud._helpers import _microseconds_from_datetime
26+
from google.cloud._helpers import _NOW
27+
from google.cloud._helpers import UTC
2828

2929

3030
def get_credentials():

core/google/cloud/exceptions.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,18 @@
2222

2323
import copy
2424
import json
25+
2526
import six
2627

2728
from google.cloud._helpers import _to_bytes
2829

29-
_HTTP_CODE_TO_EXCEPTION = {} # populated at end of module
30-
3130
try:
3231
from grpc._channel import _Rendezvous
3332
except ImportError: # pragma: NO COVER
3433
_Rendezvous = None
3534

35+
_HTTP_CODE_TO_EXCEPTION = {} # populated at end of module
36+
3637

3738
# pylint: disable=invalid-name
3839
GrpcRendezvous = _Rendezvous

core/google/cloud/future/operation.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,12 @@
1717
import functools
1818
import threading
1919

20-
from google.longrunning import operations_pb2
21-
from google.protobuf import json_format
22-
from google.rpc import code_pb2
23-
2420
from google.cloud import _helpers
2521
from google.cloud import exceptions
2622
from google.cloud.future import polling
23+
from google.longrunning import operations_pb2
24+
from google.protobuf import json_format
25+
from google.rpc import code_pb2
2726

2827

2928
class Operation(polling.PollingFuture):

core/nox.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ def lint(session):
5353
session.install(
5454
'flake8', 'flake8-import-order', 'pylint', 'gcp-devrel-py-tools')
5555
session.install('.')
56-
session.run('flake8', 'google/cloud/core')
56+
session.run('flake8', 'google', 'tests')
5757
session.run(
5858
'gcp-devrel-py-tools', 'run-pylint',
5959
'--config', 'pylint.config.py',

core/tests/unit/test_credentials.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import unittest
1616

1717
import mock
18+
import six
1819

1920

2021
class Test_get_credentials(unittest.TestCase):
@@ -169,12 +170,10 @@ def test_w_int(self):
169170
self.assertEqual(self._call_fut(123), 123)
170171

171172
def test_w_long(self):
172-
try:
173-
long
174-
except NameError: # pragma: NO COVER Py3K
175-
pass
176-
else:
177-
self.assertEqual(self._call_fut(long(123)), 123)
173+
if six.PY3:
174+
raise unittest.SkipTest('No long on Python 3')
175+
176+
self.assertEqual(self._call_fut(long(123)), 123) # noqa: F821
178177

179178
def test_w_naive_datetime(self):
180179
import datetime

core/tests/unit/test_iam.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ def test_from_api_repr_complete(self):
200200
{'role': VIEWER_ROLE, 'members': [VIEWER1, VIEWER2]},
201201
],
202202
}
203-
empty = frozenset()
204203
klass = self._get_target_class()
205204
policy = klass.from_api_repr(RESOURCE)
206205
self.assertEqual(policy.etag, 'DEADBEEF')

0 commit comments

Comments
 (0)