diff --git a/gcloud/bigquery/test_dataset.py b/gcloud/bigquery/test_dataset.py index e1caa1f81dff..cfa6c27c17a5 100644 --- a/gcloud/bigquery/test_dataset.py +++ b/gcloud/bigquery/test_dataset.py @@ -636,8 +636,6 @@ def test_delete_w_alternate_client(self): self.assertEqual(req['path'], '/%s' % PATH) def test_list_tables_empty(self): - from gcloud.bigquery.table import Table - conn = _Connection({}) client = _Client(project=self.PROJECT, connection=conn) dataset = self._makeOne(self.DS_NAME, client=client) diff --git a/gcloud/bigquery/test_query.py b/gcloud/bigquery/test_query.py index c0e21541c5a7..4fcb3274c12c 100644 --- a/gcloud/bigquery/test_query.py +++ b/gcloud/bigquery/test_query.py @@ -323,8 +323,6 @@ def __init__(self, *responses): self._requested = [] def api_request(self, **kw): - from gcloud.exceptions import NotFound self._requested.append(kw) - response, self._responses = self._responses[0], self._responses[1:] return response diff --git a/gcloud/bigquery/test_table.py b/gcloud/bigquery/test_table.py index a0edf9242824..7aa6e52de1e5 100644 --- a/gcloud/bigquery/test_table.py +++ b/gcloud/bigquery/test_table.py @@ -834,7 +834,6 @@ def test_update_w_alternate_client(self): import datetime from gcloud._helpers import UTC from gcloud._helpers import _millis - from gcloud.bigquery.table import SchemaField PATH = 'projects/%s/datasets/%s/tables/%s' % ( self.PROJECT, self.DS_NAME, self.TABLE_NAME) diff --git a/gcloud/dns/test_changes.py b/gcloud/dns/test_changes.py index f7902a106bc9..ed278a5b058f 100644 --- a/gcloud/dns/test_changes.py +++ b/gcloud/dns/test_changes.py @@ -56,7 +56,6 @@ def _makeResource(self): def _verifyResourceProperties(self, changes, resource, zone): from gcloud._helpers import _rfc3339_to_datetime - from gcloud._helpers import UTC self.assertEqual(changes.name, resource['id']) started = _rfc3339_to_datetime(resource['startTime']) self.assertEqual(changes.started, started) diff --git a/gcloud/storage/test_acl.py b/gcloud/storage/test_acl.py index bb8dbea85404..a3fd2d22c8c6 100644 --- a/gcloud/storage/test_acl.py +++ b/gcloud/storage/test_acl.py @@ -800,7 +800,6 @@ def __init__(self, *responses): self._deleted = [] def api_request(self, **kw): - from gcloud.exceptions import NotFound self._requested.append(kw) response, self._responses = self._responses[0], self._responses[1:] return response diff --git a/scripts/pylintrc_default b/scripts/pylintrc_default index e68626855dc3..413ccd72ba41 100644 --- a/scripts/pylintrc_default +++ b/scripts/pylintrc_default @@ -90,6 +90,13 @@ load-plugins=pylint.extensions.check_docs # - no-name-in-module: Error gives a lot of false positives for names which # are defined dynamically. Also, any truly missing names # will be detected by our 100% code coverage. +# +# New opinions in pylint 1.6, enforcing PEP 257. #1968 for eventual fixes +# - catching-non-exception +# - missing-raises-doc +# - missing-returns-doc +# - redundant-returns-doc +# - ungrouped-imports disable = maybe-no-member, no-member, @@ -99,6 +106,11 @@ disable = redefined-variable-type, wrong-import-position, no-name-in-module, + catching-non-exception, + missing-raises-doc, + missing-returns-doc, + redundant-returns-doc, + ungrouped-imports [REPORTS] diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index 48a393153368..52449e352828 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -37,6 +37,10 @@ ] IGNORED_FILES = [ os.path.join('docs', 'conf.py'), + # Both these files cause pylint 1.6 to barf. See: + # https://github.com/PyCQA/pylint/issues/998 + os.path.join('gcloud', 'bigtable', 'happybase', 'connection.py'), + os.path.join('gcloud', 'streaming', 'http_wrapper.py'), 'setup.py', ] SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) @@ -51,8 +55,6 @@ 'import-error', 'invalid-name', 'missing-docstring', - 'missing-raises-doc', - 'missing-returns-doc', 'no-init', 'no-self-use', 'superfluous-parens', @@ -227,13 +229,17 @@ def lint_fileset(filenames, rcfile, description): if os.path.exists(filename)] if filenames: rc_flag = '--rcfile=%s' % (rcfile,) - pylint_shell_command = ['pylint', rc_flag] + filenames - status_code = subprocess.call(pylint_shell_command) - if status_code != 0: - error_message = ('Pylint failed on %s with ' - 'status %d.' % (description, status_code)) - print(error_message, file=sys.stderr) - sys.exit(status_code) + pylint_shell_command = ['pylint', rc_flag] + errors = {} # filename -> status_code + for filename in filenames: + cmd = pylint_shell_command + [filename] + status_code = subprocess.call(cmd) + if status_code != 0: + errors[filename] = status_code + if errors: + for filename, status_code in sorted(errors.items()): + print('%-30s: %d' % (filename, status_code), file=sys.stderr) + sys.exit(len(errors)) else: print('Skipping %s, no files to lint.' % (description,))