From 844ec530ccfd43c37c97c865df23170c9a708073 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 11 Jul 2016 17:05:06 -0400 Subject: [PATCH 1/5] Drop unused imports flagged by pylint 1.6. --- gcloud/bigquery/test_dataset.py | 2 -- gcloud/bigquery/test_query.py | 2 -- gcloud/bigquery/test_table.py | 1 - gcloud/dns/test_changes.py | 1 - gcloud/storage/test_acl.py | 1 - 5 files changed, 7 deletions(-) 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 From 06800cf7b6edeb79760614e96ed417a1d32fcd7f Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 11 Jul 2016 17:06:22 -0400 Subject: [PATCH 2/5] Suppress new pylint 1.6 opinions for *all* files, not just tests. See #1968 for eventual reversal. This change reverts #1957 in favor of a more global suppression. --- scripts/pylintrc_default | 12 ++++++++++++ scripts/run_pylint.py | 2 -- 2 files changed, 12 insertions(+), 2 deletions(-) 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..7fa7662efb07 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -51,8 +51,6 @@ 'import-error', 'invalid-name', 'missing-docstring', - 'missing-raises-doc', - 'missing-returns-doc', 'no-init', 'no-self-use', 'superfluous-parens', From dec0c8b5517bbafceb1344f4011117a4f8cd0b81 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 11 Jul 2016 17:07:09 -0400 Subject: [PATCH 3/5] Suppress pylint-1.6-choking file. --- scripts/run_pylint.py | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index 7fa7662efb07..89e236856ff6 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -37,6 +37,7 @@ ] IGNORED_FILES = [ os.path.join('docs', 'conf.py'), + os.path.join('gcloud', 'streaming', 'http_wrapper.py'), 'setup.py', ] SCRIPTS_DIR = os.path.abspath(os.path.dirname(__file__)) From 7d1748286e3f715d877a1d1dba46da967a3a22ec Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 11 Jul 2016 17:32:19 -0400 Subject: [PATCH 4/5] Continue testing all files in a set even if one exits w/ non-zero status. --- scripts/run_pylint.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index 89e236856ff6..a972c2c888f2 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -226,13 +226,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,)) From 1285d8c1913dcd27d68763761e0abc2415ccc074 Mon Sep 17 00:00:00 2001 From: Tres Seaver Date: Mon, 11 Jul 2016 17:32:57 -0400 Subject: [PATCH 5/5] Skip checking two files which cause pylint 1.6 to barf. See: https://github.com/PyCQA/pylint/issues/998. --- scripts/run_pylint.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/run_pylint.py b/scripts/run_pylint.py index a972c2c888f2..52449e352828 100644 --- a/scripts/run_pylint.py +++ b/scripts/run_pylint.py @@ -37,6 +37,9 @@ ] 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', ]