Enable several checks and do not check docs/source/conf.py

* E265 block comment should start with '# '
* H302 import only modules

Do not check docs/source/conf.py. The file is imported from the
cookiecutter template.

Documented why checks are ignored and if they should be enabled
in the future.

Change-Id: I367064ecaa6d1fd9d918f7ce003303e2db660647
This commit is contained in:
Christian Berendt 2014-08-05 21:35:12 +02:00
parent 77991e571b
commit 33058cbe8e
9 changed files with 60 additions and 26 deletions

View File

@ -219,7 +219,7 @@ class NovaClientArgumentParser(argparse.ArgumentParser):
exits. exits.
""" """
self.print_usage(sys.stderr) self.print_usage(sys.stderr)
#FIXME(lzyeval): if changes occur in argparse.ArgParser._check_value # FIXME(lzyeval): if changes occur in argparse.ArgParser._check_value
choose_from = ' (choose from' choose_from = ' (choose from'
progparts = self.prog.partition(' ') progparts = self.prog.partition(' ')
self.exit(2, _("error: %(errmsg)s\nTry '%(mainp)s help %(subp)s'" self.exit(2, _("error: %(errmsg)s\nTry '%(mainp)s help %(subp)s'"
@ -360,8 +360,8 @@ class OpenStackComputeShell(object):
# thinking usage-list --end is ambiguous; but it # thinking usage-list --end is ambiguous; but it
# works fine with only --endpoint-type present # works fine with only --endpoint-type present
# Go figure. I'm leaving this here for doc purposes. # Go figure. I'm leaving this here for doc purposes.
#parser.add_argument('--endpoint_type', # parser.add_argument('--endpoint_type',
# help=argparse.SUPPRESS) # help=argparse.SUPPRESS)
parser.add_argument('--os-compute-api-version', parser.add_argument('--os-compute-api-version',
metavar='<compute-api-ver>', metavar='<compute-api-ver>',
@ -607,7 +607,7 @@ class OpenStackComputeShell(object):
must_auth = not (cliutils.isunauthenticated(args.func) must_auth = not (cliutils.isunauthenticated(args.func)
or (auth_token and management_url)) or (auth_token and management_url))
#FIXME(usrleon): Here should be restrict for project id same as # FIXME(usrleon): Here should be restrict for project id same as
# for os_username or os_password but for compatibility it is not. # for os_username or os_password but for compatibility it is not.
if must_auth: if must_auth:
if auth_plugin: if auth_plugin:

View File

@ -11,7 +11,7 @@
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from distutils.version import StrictVersion import distutils.version as dist_version
import re import re
import sys import sys
@ -200,7 +200,8 @@ class ShellTest(utils.TestCase):
# default output of empty tables differs depending between prettytable # default output of empty tables differs depending between prettytable
# versions # versions
if (hasattr(prettytable, '__version__') and if (hasattr(prettytable, '__version__') and
StrictVersion(prettytable.__version__) < StrictVersion('0.7.2')): dist_version.StrictVersion(prettytable.__version__) <
dist_version.StrictVersion('0.7.2')):
ex = '\n' ex = '\n'
else: else:
ex = ( ex = (

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from datetime import datetime import datetime
import six import six
from six.moves.urllib import parse from six.moves.urllib import parse
@ -1495,13 +1495,17 @@ class FakeHTTPClient(base_client.HTTPClient):
'zone': 'nova', 'zone': 'nova',
'status': 'enabled', 'status': 'enabled',
'state': 'up', 'state': 'up',
'updated_at': datetime(2012, 10, 29, 13, 42, 2)}, 'updated_at': datetime.datetime(
2012, 10, 29, 13, 42, 2
)},
{'binary': binary, {'binary': binary,
'host': host, 'host': host,
'zone': 'nova', 'zone': 'nova',
'status': 'disabled', 'status': 'disabled',
'state': 'down', 'state': 'down',
'updated_at': datetime(2012, 9, 18, 8, 3, 38)}, 'updated_at': datetime.datetime(
2012, 9, 18, 8, 3, 38
)},
]}) ]})
def put_os_services_enable(self, body, **kw): def put_os_services_enable(self, body, **kw):
@ -1785,7 +1789,9 @@ class FakeHTTPClient(base_client.HTTPClient):
"nova-compute": {"active": True, "nova-compute": {"active": True,
"available": True, "available": True,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 25, 0)}}}}, datetime.datetime(
2012, 12, 26, 14, 45, 25, 0
)}}}},
{"zoneName": "internal", {"zoneName": "internal",
"zoneState": {"available": True}, "zoneState": {"available": True},
"hosts": { "hosts": {
@ -1794,13 +1800,17 @@ class FakeHTTPClient(base_client.HTTPClient):
"active": True, "active": True,
"available": True, "available": True,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 25, 0)}}, datetime.datetime(
2012, 12, 26, 14, 45, 25, 0
)}},
"fake_host-2": { "fake_host-2": {
"nova-network": { "nova-network": {
"active": True, "active": True,
"available": False, "available": False,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 24, 0)}}}}, datetime.datetime(
2012, 12, 26, 14, 45, 24, 0
)}}}},
{"zoneName": "zone-2", {"zoneName": "zone-2",
"zoneState": {"available": False}, "zoneState": {"available": False},
"hosts": None}]}) "hosts": None}]})

View File

@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from datetime import datetime import datetime
from novaclient.openstack.common import strutils from novaclient.openstack.common import strutils
from novaclient.tests import fakes from novaclient.tests import fakes
@ -282,7 +282,9 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
"nova-compute": {"active": True, "nova-compute": {"active": True,
"available": True, "available": True,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 25, 0)}}}}, datetime.datetime(
2012, 12, 26, 14, 45, 25, 0
)}}}},
{"zone_name": "internal", {"zone_name": "internal",
"zone_state": {"available": True}, "zone_state": {"available": True},
"hosts": { "hosts": {
@ -291,13 +293,17 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
"active": True, "active": True,
"available": True, "available": True,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 25, 0)}}, datetime.datetime(
2012, 12, 26, 14, 45, 25, 0
)}},
"fake_host-2": { "fake_host-2": {
"nova-network": { "nova-network": {
"active": True, "active": True,
"available": False, "available": False,
"updated_at": "updated_at":
datetime(2012, 12, 26, 14, 45, 24, 0)}}}}, datetime.datetime(
2012, 12, 26, 14, 45, 24, 0
)}}}},
{"zone_name": "zone-2", {"zone_name": "zone-2",
"zone_state": {"available": False}, "zone_state": {"available": False},
"hosts": None}]}) "hosts": None}]})

View File

@ -28,7 +28,8 @@ from novaclient import base
from novaclient import crypto from novaclient import crypto
from novaclient.openstack.common.gettextutils import _ from novaclient.openstack.common.gettextutils import _
from novaclient.openstack.common import strutils from novaclient.openstack.common import strutils
from novaclient.v1_1.security_groups import SecurityGroup from novaclient.v1_1 import security_groups
REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD' REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
@ -1147,7 +1148,8 @@ class ServerManager(base.BootingManagerWithFind):
""" """
return self._list('/servers/%s/os-security-groups' % return self._list('/servers/%s/os-security-groups' %
base.getid(server), 'security_groups', SecurityGroup) base.getid(server), 'security_groups',
security_groups.SecurityGroup)
def evacuate(self, server, host, on_shared_storage, password=None): def evacuate(self, server, host, on_shared_storage, password=None):
""" """

View File

@ -1151,7 +1151,7 @@ def do_image_delete(cs, args):
const=1, const=1,
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@utils.arg('--tenant', @utils.arg('--tenant',
#nova db searches by project_id # nova db searches by project_id
dest='tenant', dest='tenant',
metavar='<tenant>', metavar='<tenant>',
nargs='?', nargs='?',
@ -2581,7 +2581,7 @@ def _find_keypair(cs, keypair):
@utils.arg('--tenant', @utils.arg('--tenant',
#nova db searches by project_id # nova db searches by project_id
dest='tenant', dest='tenant',
metavar='<tenant>', metavar='<tenant>',
nargs='?', nargs='?',

View File

@ -97,7 +97,7 @@ class Client(object):
self.tenant_id = tenant_id self.tenant_id = tenant_id
self.user_id = user_id self.user_id = user_id
self.os_cache = os_cache or not no_cache self.os_cache = os_cache or not no_cache
#TODO(bnemec): Add back in v3 extensions # TODO(bnemec): Add back in v3 extensions
self.agents = agents.AgentsManager(self) self.agents = agents.AgentsManager(self)
self.aggregates = aggregates.AggregateManager(self) self.aggregates = aggregates.AggregateManager(self)
self.availability_zones = \ self.availability_zones = \

View File

@ -950,7 +950,7 @@ def do_image_delete(cs, args):
const=1, const=1,
help=argparse.SUPPRESS) help=argparse.SUPPRESS)
@utils.arg('--tenant', @utils.arg('--tenant',
#nova db searches by project_id # nova db searches by project_id
dest='tenant', dest='tenant',
metavar='<tenant>', metavar='<tenant>',
nargs='?', nargs='?',

23
tox.ini
View File

@ -26,8 +26,23 @@ commands = python setup.py testr --coverage --testr-args='{posargs}'
downloadcache = ~/cache/pip downloadcache = ~/cache/pip
[flake8] [flake8]
# TODO fix following rules from hacking 0.9 # Following checks should be enabled in the future.
# E265,H402,H405,H904 #
ignore = E12,E265,F811,F821,H302,H402,H404,H405,H904 # H404 multi line docstring should start without a leading new line
# H405 multi line docstring summary not separated with an empty line
#
# Following checks are ignored on purpose.
#
# H402 one line docstring needs punctuation
# reason: removed in hacking (https://review.openstack.org/#/c/101497/)
#
# H904 wrap long lines in parentheses instead of a backslash
# reason: removed in hacking (https://review.openstack.org/#/c/101701/)
#
# Additional checks are also ignored on purpose: E12, F811, F821
ignore = E12,F811,F821,H402,H404,H405,H904
show-source = True show-source = True
exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build exclude=.venv,.git,.tox,dist,*openstack/common*,*lib/python*,*egg,build,doc/source/conf.py
[hacking]
import_exceptions = novaclient.openstack.common.gettextutils