From 6f27af4a0cdbde42b1566ecabaf667c26b089dc3 Mon Sep 17 00:00:00 2001 From: Dolph Mathews Date: Tue, 28 May 2013 09:22:03 -0500 Subject: [PATCH] Fix unused imports(flake8 F401, F999) - F401: imported but unused - F999: syntax error in doctest Fixing a couple of the F401's simply required fixing the doctests syntax where the imports were actually in use. Change-Id: If78abbb143daf8d005a71c5ab52836df29c5e0cd --- keystoneclient/client.py | 4 ++-- keystoneclient/common/cms.py | 2 +- keystoneclient/v2_0/__init__.py | 1 + keystoneclient/v2_0/client.py | 16 ++++++++-------- keystoneclient/v3/__init__.py | 1 + keystoneclient/v3/client.py | 7 ++++--- tests/test_base.py | 4 ---- tests/test_client.py | 1 - tests/test_shell.py | 1 - tests/v2_0/fakes.py | 3 --- tests/v2_0/test_shell.py | 3 --- tests/v3/test_endpoints.py | 1 - tools/install_venv.py | 1 - tox.ini | 4 +--- 14 files changed, 18 insertions(+), 31 deletions(-) diff --git a/keystoneclient/client.py b/keystoneclient/client.py index 8e5e2bddd..5b2f1253a 100644 --- a/keystoneclient/client.py +++ b/keystoneclient/client.py @@ -35,8 +35,8 @@ _logger = logging.getLogger(__name__) def try_import_keyring(): try: - import keyring - import pickle + import keyring # noqa + import pickle # noqa return True except ImportError: if (hasattr(sys.stderr, 'isatty') and sys.stderr.isatty()): diff --git a/keystoneclient/common/cms.py b/keystoneclient/common/cms.py index f13264da0..48b991a46 100644 --- a/keystoneclient/common/cms.py +++ b/keystoneclient/common/cms.py @@ -21,7 +21,7 @@ def _ensure_subprocess(): else: import subprocess except ImportError: - import subprocess + import subprocess # noqa def cms_verify(formatted, signing_cert_file_name, ca_file_name): diff --git a/keystoneclient/v2_0/__init__.py b/keystoneclient/v2_0/__init__.py index 44ad28e7c..00ff0c1e6 100644 --- a/keystoneclient/v2_0/__init__.py +++ b/keystoneclient/v2_0/__init__.py @@ -1 +1,2 @@ +# flake8: noqa from keystoneclient.v2_0.client import Client diff --git a/keystoneclient/v2_0/client.py b/keystoneclient/v2_0/client.py index 03cb8f2e5..788bfa7c3 100644 --- a/keystoneclient/v2_0/client.py +++ b/keystoneclient/v2_0/client.py @@ -80,9 +80,9 @@ class Client(client.HTTPClient): >>> from keystoneclient.v2_0 import client >>> keystone = client.Client(username=USER, - password=PASS, - tenant_name=TENANT_NAME, - auth_url=KEYSTONE_URL) + ... password=PASS, + ... tenant_name=TENANT_NAME, + ... auth_url=KEYSTONE_URL) >>> keystone.tenants.list() ... >>> user = keystone.users.get(USER_ID) @@ -95,9 +95,9 @@ class Client(client.HTTPClient): >>> from keystoneclient.v2_0 import client >>> keystone = client.Client(username=USER, - password=PASS, - tenant_name=TENANT_NAME, - auth_url=KEYSTONE_URL) + ... password=PASS, + ... tenant_name=TENANT_NAME, + ... auth_url=KEYSTONE_URL) >>> auth_ref = keystone.auth_ref >>> # pickle or whatever you like here >>> new_client = client.Client(auth_ref=auth_ref) @@ -111,8 +111,8 @@ class Client(client.HTTPClient): >>> from keystoneclient.v2_0 import client >>> admin_client = client.Client( - token='12345secret7890', - endpoint='http://localhost:35357/v2.0') + ... token='12345secret7890', + ... endpoint='http://localhost:35357/v2.0') >>> keystone.tenants.list() """ diff --git a/keystoneclient/v3/__init__.py b/keystoneclient/v3/__init__.py index feb2536b8..82919add3 100644 --- a/keystoneclient/v3/__init__.py +++ b/keystoneclient/v3/__init__.py @@ -1 +1,2 @@ +# flake8: noqa from keystoneclient.v3.client import Client diff --git a/keystoneclient/v3/client.py b/keystoneclient/v3/client.py index f8d860c2e..c0b613ebb 100644 --- a/keystoneclient/v3/client.py +++ b/keystoneclient/v3/client.py @@ -52,9 +52,10 @@ class Client(client.Client): >>> from keystoneclient.v3 import client >>> keystone = client.Client(username=USER, - password=PASS, - tenant_name=TENANT_NAME, - auth_url=KEYSTONE_URL) + ... password=PASS, + ... tenant_name=TENANT_NAME, + ... auth_url=KEYSTONE_URL) + ... >>> keystone.tenants.list() ... >>> user = keystone.users.get(USER_ID) diff --git a/tests/test_base.py b/tests/test_base.py index e28b651cc..42d591a13 100644 --- a/tests/test_base.py +++ b/tests/test_base.py @@ -1,8 +1,4 @@ -import mock -import mox - from keystoneclient import base -from keystoneclient import exceptions from keystoneclient.v2_0 import roles from tests import utils diff --git a/tests/test_client.py b/tests/test_client.py index 90ab346be..d24d72a91 100644 --- a/tests/test_client.py +++ b/tests/test_client.py @@ -1,4 +1,3 @@ -import copy import json import mock diff --git a/tests/test_shell.py b/tests/test_shell.py index f16be8574..502c7084f 100644 --- a/tests/test_shell.py +++ b/tests/test_shell.py @@ -2,7 +2,6 @@ import argparse import cStringIO import json import os -import requests import sys import uuid diff --git a/tests/v2_0/fakes.py b/tests/v2_0/fakes.py index 47d398c76..8152322e6 100644 --- a/tests/v2_0/fakes.py +++ b/tests/v2_0/fakes.py @@ -13,11 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. -from datetime import datetime import urlparse -from keystoneclient import client as base_client -from keystoneclient.v2_0 import client from tests import fakes from tests import utils diff --git a/tests/v2_0/test_shell.py b/tests/v2_0/test_shell.py index f5c04ec68..f097a9c64 100644 --- a/tests/v2_0/test_shell.py +++ b/tests/v2_0/test_shell.py @@ -1,13 +1,10 @@ import cStringIO -import mock import os import stubout import sys from testtools import matchers -from keystoneclient import exceptions from keystoneclient import client -from keystoneclient.v2_0 import client as client_v2_0 from tests.v2_0 import fakes from tests import utils diff --git a/tests/v3/test_endpoints.py b/tests/v3/test_endpoints.py index 29bf226da..c29499f11 100644 --- a/tests/v3/test_endpoints.py +++ b/tests/v3/test_endpoints.py @@ -1,4 +1,3 @@ -import testtools import uuid from keystoneclient.v3 import endpoints diff --git a/tools/install_venv.py b/tools/install_venv.py index 6d6d2b319..f2f880694 100644 --- a/tools/install_venv.py +++ b/tools/install_venv.py @@ -24,7 +24,6 @@ Installation script for python-keystoneclient's development virtualenv """ import os -import subprocess import sys import install_venv_common as install_venv diff --git a/tox.ini b/tox.ini index c0860fbe1..324edaddb 100644 --- a/tox.ini +++ b/tox.ini @@ -27,11 +27,9 @@ commands = python setup.py testr --coverage --testr-args='{posargs}' downloadcache = ~/cache/pip [flake8] -# F401: imported but unused # F811: redefinition of unused 'client' from line 81 # F821: undefined name # F841: local variable is assigned to but never used -# F999: syntax error in doctest # H201: no 'except:' at least use 'except Exception:' # H202: assertRaises Exception too broad # H302: import only modules @@ -42,6 +40,6 @@ downloadcache = ~/cache/pip # H403: multi line docstring end on new line # H404: multi line docstring should start with a summary # H802: git commit title -ignore = F401,F811,F821,F841,F999,H201,H202,H302,H304,H306,H401,H402,H403,H404,H802 +ignore = F811,F821,F841,H201,H202,H302,H304,H306,H401,H402,H403,H404,H802 show-source = True exclude = .venv,.tox,dist,doc,*egg