Skip to content

Commit a1620a9

Browse files
authored
Merge pull request #1974 from tseaver/pylint-disable-pylint-1.6-warnings-breakage
Disable pylint 1.6 warnings / work around breakage
2 parents 2dcad57 + 1285d8c commit a1620a9

File tree

7 files changed

+27
-16
lines changed

7 files changed

+27
-16
lines changed

gcloud/bigquery/test_dataset.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -636,8 +636,6 @@ def test_delete_w_alternate_client(self):
636636
self.assertEqual(req['path'], '/%s' % PATH)
637637

638638
def test_list_tables_empty(self):
639-
from gcloud.bigquery.table import Table
640-
641639
conn = _Connection({})
642640
client = _Client(project=self.PROJECT, connection=conn)
643641
dataset = self._makeOne(self.DS_NAME, client=client)

gcloud/bigquery/test_query.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,6 @@ def __init__(self, *responses):
323323
self._requested = []
324324

325325
def api_request(self, **kw):
326-
from gcloud.exceptions import NotFound
327326
self._requested.append(kw)
328-
329327
response, self._responses = self._responses[0], self._responses[1:]
330328
return response

gcloud/bigquery/test_table.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -834,7 +834,6 @@ def test_update_w_alternate_client(self):
834834
import datetime
835835
from gcloud._helpers import UTC
836836
from gcloud._helpers import _millis
837-
from gcloud.bigquery.table import SchemaField
838837

839838
PATH = 'projects/%s/datasets/%s/tables/%s' % (
840839
self.PROJECT, self.DS_NAME, self.TABLE_NAME)

gcloud/dns/test_changes.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ def _makeResource(self):
5656

5757
def _verifyResourceProperties(self, changes, resource, zone):
5858
from gcloud._helpers import _rfc3339_to_datetime
59-
from gcloud._helpers import UTC
6059
self.assertEqual(changes.name, resource['id'])
6160
started = _rfc3339_to_datetime(resource['startTime'])
6261
self.assertEqual(changes.started, started)

gcloud/storage/test_acl.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,6 @@ def __init__(self, *responses):
800800
self._deleted = []
801801

802802
def api_request(self, **kw):
803-
from gcloud.exceptions import NotFound
804803
self._requested.append(kw)
805804
response, self._responses = self._responses[0], self._responses[1:]
806805
return response

scripts/pylintrc_default

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,13 @@ load-plugins=pylint.extensions.check_docs
9090
# - no-name-in-module: Error gives a lot of false positives for names which
9191
# are defined dynamically. Also, any truly missing names
9292
# will be detected by our 100% code coverage.
93+
#
94+
# New opinions in pylint 1.6, enforcing PEP 257. #1968 for eventual fixes
95+
# - catching-non-exception
96+
# - missing-raises-doc
97+
# - missing-returns-doc
98+
# - redundant-returns-doc
99+
# - ungrouped-imports
93100
disable =
94101
maybe-no-member,
95102
no-member,
@@ -99,6 +106,11 @@ disable =
99106
redefined-variable-type,
100107
wrong-import-position,
101108
no-name-in-module,
109+
catching-non-exception,
110+
missing-raises-doc,
111+
missing-returns-doc,
112+
redundant-returns-doc,
113+
ungrouped-imports
102114

103115

104116
[REPORTS]

scripts/run_pylint.py

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@
3737
]
3838
IGNORED_FILES = [
3939
os.path.join('docs', 'conf.py'),
40+
# Both these files cause pylint 1.6 to barf. See:
41+
# https://github.com/PyCQA/pylint/issues/998
42+
os.path.join('gcloud', 'bigtable', 'happybase', 'connection.py'),
43+
os.path.join('gcloud', 'streaming', 'http_wrapper.py'),
4044
'setup.py',
4145
]
4246
SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__))
@@ -51,8 +55,6 @@
5155
'import-error',
5256
'invalid-name',
5357
'missing-docstring',
54-
'missing-raises-doc',
55-
'missing-returns-doc',
5658
'no-init',
5759
'no-self-use',
5860
'superfluous-parens',
@@ -227,13 +229,17 @@ def lint_fileset(filenames, rcfile, description):
227229
if os.path.exists(filename)]
228230
if filenames:
229231
rc_flag = '--rcfile=%s' % (rcfile,)
230-
pylint_shell_command = ['pylint', rc_flag] + filenames
231-
status_code = subprocess.call(pylint_shell_command)
232-
if status_code != 0:
233-
error_message = ('Pylint failed on %s with '
234-
'status %d.' % (description, status_code))
235-
print(error_message, file=sys.stderr)
236-
sys.exit(status_code)
232+
pylint_shell_command = ['pylint', rc_flag]
233+
errors = {} # filename -> status_code
234+
for filename in filenames:
235+
cmd = pylint_shell_command + [filename]
236+
status_code = subprocess.call(cmd)
237+
if status_code != 0:
238+
errors[filename] = status_code
239+
if errors:
240+
for filename, status_code in sorted(errors.items()):
241+
print('%-30s: %d' % (filename, status_code), file=sys.stderr)
242+
sys.exit(len(errors))
237243
else:
238244
print('Skipping %s, no files to lint.' % (description,))
239245

0 commit comments

Comments
 (0)