Browse Source

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
Christian Berendt 4 years ago
parent
commit
33058cbe8e

+ 4
- 4
novaclient/shell.py View File

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

+ 3
- 2
novaclient/tests/test_shell.py View File

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

+ 16
- 6
novaclient/tests/v1_1/fakes.py View File

@@ -14,7 +14,7 @@
14 14
 # See the License for the specific language governing permissions and
15 15
 # limitations under the License.
16 16
 
17
-from datetime import datetime
17
+import datetime
18 18
 
19 19
 import six
20 20
 from six.moves.urllib import parse
@@ -1495,13 +1495,17 @@ class FakeHTTPClient(base_client.HTTPClient):
1495 1495
                        'zone': 'nova',
1496 1496
                        'status': 'enabled',
1497 1497
                        'state': 'up',
1498
-                       'updated_at': datetime(2012, 10, 29, 13, 42, 2)},
1498
+                       'updated_at': datetime.datetime(
1499
+                           2012, 10, 29, 13, 42, 2
1500
+                       )},
1499 1501
                       {'binary': binary,
1500 1502
                        'host': host,
1501 1503
                        'zone': 'nova',
1502 1504
                        'status': 'disabled',
1503 1505
                        'state': 'down',
1504
-                       'updated_at': datetime(2012, 9, 18, 8, 3, 38)},
1506
+                       'updated_at': datetime.datetime(
1507
+                           2012, 9, 18, 8, 3, 38
1508
+                       )},
1505 1509
                       ]})
1506 1510
 
1507 1511
     def put_os_services_enable(self, body, **kw):
@@ -1785,7 +1789,9 @@ class FakeHTTPClient(base_client.HTTPClient):
1785 1789
                                        "nova-compute": {"active": True,
1786 1790
                                            "available": True,
1787 1791
                                            "updated_at":
1788
-                                   datetime(2012, 12, 26, 14, 45, 25, 0)}}}},
1792
+                                   datetime.datetime(
1793
+                                       2012, 12, 26, 14, 45, 25, 0
1794
+                                   )}}}},
1789 1795
                               {"zoneName": "internal",
1790 1796
                                "zoneState": {"available": True},
1791 1797
                                "hosts": {
@@ -1794,13 +1800,17 @@ class FakeHTTPClient(base_client.HTTPClient):
1794 1800
                                            "active": True,
1795 1801
                                            "available": True,
1796 1802
                                            "updated_at":
1797
-                                   datetime(2012, 12, 26, 14, 45, 25, 0)}},
1803
+                                   datetime.datetime(
1804
+                                       2012, 12, 26, 14, 45, 25, 0
1805
+                                   )}},
1798 1806
                                    "fake_host-2": {
1799 1807
                                        "nova-network": {
1800 1808
                                            "active": True,
1801 1809
                                            "available": False,
1802 1810
                                            "updated_at":
1803
-                                   datetime(2012, 12, 26, 14, 45, 24, 0)}}}},
1811
+                                   datetime.datetime(
1812
+                                       2012, 12, 26, 14, 45, 24, 0
1813
+                                   )}}}},
1804 1814
                               {"zoneName": "zone-2",
1805 1815
                                "zoneState": {"available": False},
1806 1816
                                "hosts": None}]})

+ 10
- 4
novaclient/tests/v3/fakes.py View File

@@ -14,7 +14,7 @@
14 14
 # See the License for the specific language governing permissions and
15 15
 # limitations under the License.
16 16
 
17
-from datetime import datetime
17
+import datetime
18 18
 
19 19
 from novaclient.openstack.common import strutils
20 20
 from novaclient.tests import fakes
@@ -282,7 +282,9 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
282 282
                                        "nova-compute": {"active": True,
283 283
                                            "available": True,
284 284
                                            "updated_at":
285
-                                   datetime(2012, 12, 26, 14, 45, 25, 0)}}}},
285
+                                   datetime.datetime(
286
+                                       2012, 12, 26, 14, 45, 25, 0
287
+                                   )}}}},
286 288
                               {"zone_name": "internal",
287 289
                                "zone_state": {"available": True},
288 290
                                "hosts": {
@@ -291,13 +293,17 @@ class FakeHTTPClient(fakes_v1_1.FakeHTTPClient):
291 293
                                            "active": True,
292 294
                                            "available": True,
293 295
                                            "updated_at":
294
-                                   datetime(2012, 12, 26, 14, 45, 25, 0)}},
296
+                                   datetime.datetime(
297
+                                       2012, 12, 26, 14, 45, 25, 0
298
+                                   )}},
295 299
                                    "fake_host-2": {
296 300
                                        "nova-network": {
297 301
                                            "active": True,
298 302
                                            "available": False,
299 303
                                            "updated_at":
300
-                                   datetime(2012, 12, 26, 14, 45, 24, 0)}}}},
304
+                                   datetime.datetime(
305
+                                       2012, 12, 26, 14, 45, 24, 0
306
+                                   )}}}},
301 307
                               {"zone_name": "zone-2",
302 308
                                "zone_state": {"available": False},
303 309
                                "hosts": None}]})

+ 4
- 2
novaclient/v1_1/servers.py View File

@@ -28,7 +28,8 @@ from novaclient import base
28 28
 from novaclient import crypto
29 29
 from novaclient.openstack.common.gettextutils import _
30 30
 from novaclient.openstack.common import strutils
31
-from novaclient.v1_1.security_groups import SecurityGroup
31
+from novaclient.v1_1 import security_groups
32
+
32 33
 
33 34
 REBOOT_SOFT, REBOOT_HARD = 'SOFT', 'HARD'
34 35
 
@@ -1147,7 +1148,8 @@ class ServerManager(base.BootingManagerWithFind):
1147 1148
 
1148 1149
         """
1149 1150
         return self._list('/servers/%s/os-security-groups' %
1150
-                          base.getid(server), 'security_groups', SecurityGroup)
1151
+                          base.getid(server), 'security_groups',
1152
+                          security_groups.SecurityGroup)
1151 1153
 
1152 1154
     def evacuate(self, server, host, on_shared_storage, password=None):
1153 1155
         """

+ 2
- 2
novaclient/v1_1/shell.py View File

@@ -1151,7 +1151,7 @@ def do_image_delete(cs, args):
1151 1151
     const=1,
1152 1152
     help=argparse.SUPPRESS)
1153 1153
 @utils.arg('--tenant',
1154
-    #nova db searches by project_id
1154
+    # nova db searches by project_id
1155 1155
     dest='tenant',
1156 1156
     metavar='<tenant>',
1157 1157
     nargs='?',
@@ -2581,7 +2581,7 @@ def _find_keypair(cs, keypair):
2581 2581
 
2582 2582
 
2583 2583
 @utils.arg('--tenant',
2584
-           #nova db searches by project_id
2584
+           # nova db searches by project_id
2585 2585
            dest='tenant',
2586 2586
            metavar='<tenant>',
2587 2587
            nargs='?',

+ 1
- 1
novaclient/v3/client.py View File

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

+ 1
- 1
novaclient/v3/shell.py View File

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

+ 19
- 4
tox.ini View File

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

Loading…
Cancel
Save