Commit Graph

43 Commits

Author SHA1 Message Date
Takashi Kajinami bced896d37 Remove workaround for old django-pyscss
This reverts the change[1] made earlier to workaround the issue caused
by usage of vendored version of six library in the django-pyscss
library.

The django-pyscss library no longer imports the vendored version of
six, since 2.0.3[2].

[1] 39f28ad5ed
[2] 1499332e1d

Change-Id: I22802b75d6a8d8f35930709e89d64dd65982cef0
2024-02-02 03:23:43 +09:00
Akihiro Motoki e5d09edc20 Use python3-style super()
In python3, super() does not always require a class and self reference.
In other words, super() is enough for most cases.
This is much simpler and it is time to switch it to the newer style.

pylint provides a check for this.
Let's enable 'super-with-arguments' check.

NOTE: _prepare_mappings() method of FormRegion in
openstack_dashboard/test/integration_tests/regions/forms.py is refactored.
super() (without explicit class and self referece) does not work when
a subclass method calls a same method in a parent class multiple times.
It looks better to prepare a separate method to provide a common logic.

Change-Id: Id9512a14be9f20dbd5ebd63d446570c7b7c825ff
2020-10-15 14:37:20 +09:00
Akihiro Motoki 74df97f57c pylint: Fix unnecessary-comprehension warning
'unnecessary-comprehension' warning is emitted when
unnecessary use of a comprehension is found.

classes attribute in Action can be a tuple,
so we need list() to ensure it is a list before adding 'disabled'.
I think it is time to introduce a method in Action class or somewhere
but it should be handled separately.

Change-Id: I16a98d56b6d0bd0af234b00735c6ed576620df7e
2020-09-27 12:44:16 +09:00
Akihiro Motoki 692778f8cf pylint: Address no-else-return warning
This pylint check 'no-else-return' might be debatable.
but as far as I checked it works in most cases.

Change-Id: Ie8574d4a529454c6e050fa62a7a17ea097d00240
2020-09-27 12:44:16 +09:00
Akihiro Motoki b67ad564c4 pylint: Address no-else-continue/no-else-raise warnings
Change-Id: I1d44c1bf564cf02908113a42b98e06057e993ec7
2020-09-27 12:44:16 +09:00
Akihiro Motoki de509f9914 Follow-up on pylint upgrade
* Adds comments on pylint disabled checks
* Enable 'deprecated-method' check. We have no failures now.
* Convert global disabled checks 'no-value-for-parameter' and
  'using-constant-test' to per-comment disables.

Other cleanup would be larger and/or better to be visited separately.

Change-Id: Id47dc8de4abcc8c744d96d2accf3a2a09ae206d4
2020-09-27 12:44:16 +09:00
Akihiro Motoki 235cbb839e Bump pylint version to support python3.8
pylint 2.2.2 which we currently use does not support python 3.8 [1].

Let's use a newer version of pylint.

pylint now declares strict versions for astroid and isort,
so we do not need to manage them in our test-requirements.txt.

All new checks are disabled temporarily. Let's visit them later and
judge whether we disable them permanently one by one.

[1] https://github.com/PyCQA/pylint/issues/2737

Change-Id: I106b250e632305365aaab4d881c9ba5ea93505b3
2020-09-10 11:43:57 +09:00
Yves-Gwenael Bourhis 66144165ff Use the python real executable
Use the real python executable as shebang
Use exec instead of execfile if using python 3

Change-Id: I8acea40851c7e9dc248751be967859b2b9430af7
Closes-Bug: #1836580
2019-07-17 16:23:33 +02:00
Akihiro Motoki 949802264e pylint: fix cyclic-import
openstack_dashboard/api nova.py and cinder.py are imported
by each other. To avoid cyclic imports, some imports are placed
inside functions now, but it would be nice if we can move them
to a separate module and nova.py/cinder.py can import it.

This commit tries to achieve this by moving some stuffs in nova.py
into a separate module named _nova.py.
The module name starts with an underscore to clarify
it is intended to use only in openstack_dashboard.api.

Change-Id: If91cf4f30d2ddab471757129c2a74b26b6d38b1e
2019-02-09 21:08:48 +09:00
Akihiro Motoki a984ae43e5 pylint: fix raising-non-exception error
django.http.HttpResponseNotFound is not an exception.
Django recommends to return it. @rest_utils.ajax can handle it.

Change-Id: I26f82da022a2c2725d62cc136c5da8eafc0ac26f
2019-01-20 05:48:09 +09:00
Akihiro Motoki 9518f7a5e7 pylint: fix unexpected-keyword-arg error
horizon/forms/fields.py:
ThemableCheckboxSelectMultiple.__init__ does not have
arguments "name" and "value". They were specified before somehow.

openstack_dashboard/dashboards/project/instances/forms.py:
messages.error() does not have "redirect" argument.
We need to redirect explicitly.

Change-Id: Ib51abf136fb49e3be65005c5f48715f004379178
2019-01-17 03:29:56 +09:00
Zuul 64542397d8 Merge "pylint: fix too-many-nested-blocks/redefined-argument-from-local" 2019-01-16 17:57:15 +00:00
Zuul 60dd57655b Merge "pylint: fix some refactor recommendations" 2019-01-16 17:57:12 +00:00
Zuul d9e992a4cb Merge "pylint: fix redundant-keyword-arg error" 2019-01-16 17:57:09 +00:00
Zuul 272256e00f Merge "pylint: Ignore existing misplaced-bare-raise error" 2019-01-16 17:57:07 +00:00
Akihiro Motoki 0d39a5c33a pylint: Ignore existing misplaced-bare-raise error
Change-Id: I8bb2b64cb51f297cac53bf042d4d2bd1fdb0a159
2019-01-17 00:51:04 +09:00
Akihiro Motoki 150dcc3fb0 pylint: fix redundant-keyword-arg error
pylint complains 'name' argument is redundant
in positional and keyword arguments.
The existence of 'name' in kwargs is checked before passing to
api.keystone.tenant_create, so we can pass 'name' as part of kwargs.

Change-Id: Ice09cecb21217b042d44a8c1dda7a4736e2b391b
2019-01-17 00:47:31 +09:00
Akihiro Motoki 7c585e2643 pylint: fix some refactor recommendations
openstack_dashboard/dashboards/project/security_groups/forms.py:393:13: R1714: Consider merging these comparisons with "in" to "rule_menu in ('tcp', 'udp')" (consider-using-in)
openstack_dashboard/api/rest/json_encoder.py:61:15: R0124: Redundant comparison - o != o (comparison-with-itself)
openstack_dashboard/api/keystone.py:904:15: R1714: Consider merging these comparisons with "in" to 'default in (role.id, role.name)' (consider-using-in)
horizon/templatetags/truncate_filter.py:30:7: R1716: Simplify chained comparison between the operands (chained-comparison)

Change-Id: I6cf8602f88c4027ff12aaa4ea5a9f2069ae2e2a6
2019-01-17 00:44:19 +09:00
Akihiro Motoki 9578949638 pylint: fix too-many-nested-blocks/redefined-argument-from-local
openstack_dashboard/dashboards/project/cgroups/workflows.py:313:8: R1702: Too many nested blocks (6/5) (too-many-nested-blocks)
openstack_auth/plugin/base.py:221:12: R1704: Redefining argument with the local name 'domain_name' (redefined-argument-from-local)
horizon/tables/formset.py:59:16: R1704: Redefining argument with the local name 'column' (redefined-argument-from-local)

Change-Id: Ifeb192efac83c0b2d5399c51f66c8fb8f8969fc0
2019-01-17 00:41:20 +09:00
Akihiro Motoki ac7ac272b3 pylint: fix several coding convention violations
openstack_dashboard/context_processors.py:94:15: C0122: Comparison should be link['url'] != 'horizon:project:api_access:openrcv2' (misplaced-comparison-constant)
openstack_dashboard/settings.py:467:4: C0412: Imports from package horizon are not grouped (ungrouped-imports)
openstack_dashboard/enabled/_1370_project_vg_snapshots.py:9:0: C0301: Line too long (86/80) (line-too-long)
openstack_dashboard/enabled/_1360_project_volume_groups.py:9:0: C0301: Line too long (85/80) (line-too-long)
openstack_dashboard/usage/base.py:62:8: W0106: Expression "[instance_list.extend(u.server_usages) for u in self.usage_list]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:43:12: W0106: Expression "[public_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/dashboards/project/images/utils.py:75:12: W0106: Expression "[community_images.append(image) for image in images]" is assigned to nothing (expression-not-assigned)
openstack_dashboard/api/glance.py:47:4: C0412: Imports from package glanceclient are not grouped (ungrouped-imports)
openstack_dashboard/api/cinder.py:60:4: C0412: Imports from package cinderclient are not grouped (ungrouped-imports)
openstack_auth/user.py:358:4: E0211: Method has no argument (no-method-argument)
openstack_auth/user.py:362:4: E0211: Method has no argument (no-method-argument)
openstack_dashboard/api/keystone.py:75:4: C0412: Imports from package keystoneclient are not grouped (ungrouped-imports)
horizon/loaders.py:43:16: W0706: The except handler raises immediately (try-except-raise)
horizon/themes.py:174:8: W0706: The except handler raises immediately (try-except-raise)

Change-Id: I40cf3ffbc4519657e11180d2e2fe7401387c5556
2019-01-17 00:05:27 +09:00
Zuul c9536342c2 Merge "pylint: fix len-as-condition warning" 2019-01-16 14:25:39 +00:00
Zuul 32f5338a4f Merge "pylint: fix useless-super-delegation warning" 2019-01-16 14:25:24 +00:00
Zuul 5dcf0db34b Merge "pylint: fix trailing-comma-tuple warning" 2019-01-16 14:25:21 +00:00
Zuul d0a1a16415 Merge "pylint: fix unnecessary-pass warning" 2019-01-16 14:25:19 +00:00
Zuul e62a6bff13 Merge "pylint: fix simplifiable-if-statement/expression" 2019-01-16 14:25:17 +00:00
Akihiro Motoki 4dd8e3d407 pylint: fix bad-mcs-classmethod-argument warning
Change-Id: Idfa421774ac23f673007fe7a7381c5199ccda5e0
2019-01-16 13:16:55 +09:00
Akihiro Motoki f6e1338cde pylint: fix unnecessary-pass warning
Change-Id: Ie2e5c6482a19553f6c73c50555d65834bb62ca9e
2019-01-16 13:10:16 +09:00
Akihiro Motoki a8edb5059d pylint: fix simplifiable-if-statement/expression
Change-Id: I9af66f886c47d3d2be61cba22b6c84460a178b8e
2019-01-16 13:08:08 +09:00
Akihiro Motoki 786fb183e8 pylint: fix trailing-comma-tuple warning
Change-Id: I72fa6cacef70e80f95b76e2aa3cefbffad73edb5
2019-01-16 13:06:55 +09:00
Akihiro Motoki e9f75a7bcb pylint: fix useless-super-delegation warning
Change-Id: Iddea27e720dc7184fa3d524a2a465732f18d4dee
2019-01-16 13:05:09 +09:00
Akihiro Motoki c076db20c8 pylint: fix len-as-condition warning
Change-Id: Ib89c1854ad42b96e4caf281160d568fe98430afe
2019-01-16 12:56:20 +09:00
Akihiro Motoki 3143edef01 pylint: fix import-error
It seems pylint cannot handle distutils imports
and shows "import-error" error. I believe it sounds
reasonable to ignore this case.

Change-Id: Ia08b4fbf8c3270aa37cd88967add8258f6b26377
2019-01-16 00:00:58 +09:00
Akihiro Motoki 6ce323307d pylint: fixes several errors
openstack_dashboard/hooks.py:16:0: E0611: No name 'command' in module 'distutils' (no-name-in-module)

openstack_dashboard/dashboards/project/networks/ports/sg_base.py:52:12: E1111: Assigning result of a function call, where the function has no return (assignment-from-no-return)
BaseSecurityGroupsAction._get_initial_security_groups() is now marked
as abstract method because this method must be implemented in subclasses.
BaseSecurityGroupsAction.handle() is now dropped because there is
no difference from the parent class (horizon.workflows.Action).

openstack_auth/views.py:211:4: E1206: Not enough arguments for logging format string (logging-too-few-args)
openstack_auth/views.py:269:8: E1206: Not enough arguments for logging format string (logging-too-few-args)
openstack_auth/plugin/base.py:237:20: E1206: Not enough arguments for logging format string (logging-too-few-args)

horizon/base.py:166:24: E1133: Non-iterable value self.policy_rules is used in an iterating context (not-an-iterable)
horizon/tabs/base.py:489:40: E1133: Non-iterable value self.table_classes is used in an iterating context (not-an-iterable)

Change-Id: I0b045d04af251854b5017c9f698e3b40503a0724
2019-01-16 00:00:07 +09:00
Zuul 6299fdbdc0 Merge "pylint: fix several warnings" 2019-01-15 11:22:36 +00:00
Zuul f1fb3d168c Merge "pylint: ignore access-member-before-definition explicitly" 2019-01-15 11:22:29 +00:00
Zuul 071b5c9fa9 Merge "pylint: Drop non-existing IPAddressField" 2019-01-15 11:22:27 +00:00
Akihiro Motoki f3bd271fc9 pylint: fix bad-super-call
Change-Id: Ia81e5c8b77dbfcb48630b1736d581cdff73278ef
2019-01-15 01:11:33 +09:00
Akihiro Motoki 51251d9d67 pylint: Drop non-existing IPAddressField
horizon/forms/__init__.py exposed IPAddressField via __all__,
but IPAddressField does not exist in Django code.
It addresses pylint undefined-all-variable error.

Change-Id: I5e5cc802c0d75e91fad769cc381368b532561476
2019-01-15 01:07:04 +09:00
Akihiro Motoki 86d1826a29 pylint: ignore access-member-before-definition explicitly
In case of Cell.status property, the code has a good readability,
so it sounds reasonable to ignore access-member-before-definition,
although access-member-before-definition itself is a useful check.

Change-Id: Ic6f2ec42bac41c62265e6b0e744c256007093ce6
2019-01-15 01:05:49 +09:00
Akihiro Motoki 6e1348d05f pylint: fix several warnings
openstack_dashboard/theme_settings.py:63:8: W1201: Specify string format arguments as logging function parameters (logging-not-lazy)
openstack_dashboard/settings.py:412:24: W0122: Use of exec (exec-used)
openstack_dashboard/dashboards/identity/domains/workflows.py:476:44: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/identity/projects/workflows.py:906:49: W0640: Cell variable group_id defined in loop (cell-var-from-loop)
openstack_dashboard/dashboards/admin/networks/views.py:42:0: W0404: Reimport 'views' (imported line 28) (reimported)
openstack_dashboard/api/swift.py:204:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/swift.py:214:0: W0102: Dangerous default value {} as argument (dangerous-default-value)
openstack_dashboard/api/cinder.py:248:30: W0631: Using possibly undefined loop variable 'cinder_url' (undefined-loop-variable)
openstack_auth/backend.py:123:28: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:129:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/backend.py:131:39: W0631: Using possibly undefined loop variable 'plugin' (undefined-loop-variable)
openstack_auth/views.py:39:0: W0611: Unused Login imported from openstack_auth.forms (unused-import)
horizon/exceptions.py:348:8: W0125: Using a conditional statement with a constant value (using-constant-test)
horizon/tables/base.py:353:12: W0715: Exception arguments suggest string formatting might be intended (raising-format-tuple)

Change-Id: Icf4f22abda77c9dbf98c780de876b7836c31d669
2019-01-15 00:22:27 +09:00
Akihiro Motoki 59beb951a3 pylint: Fix consider-using-(dict|set)-comprehension
Change-Id: I81c694c17106c179a53326a12e78cfa899872970
2019-01-13 00:59:05 +09:00
Akihiro Motoki 220b1346bd Enable pylint in horizon
tests.py files are excluded from targets checked by pylint
because it takes longer and longer time to check them somehow.

pylint 2.2.x is supported only in Python 3 and we already switched
our pep8 basepython to python3, so pylint and astroid are installed
only for python3. This seems the easiest way to ensure py27 env works.

literal-comparison error in openstack_dashboard/api/nova.py
is also fixed in this commit as it is simple enough.

Change-Id: Ic8868a44b296dba457be721716ca6f9d37ad9369
2019-01-12 22:41:20 +09:00
Joe Heck 6d633a9ec7 updating run_tests.sh to mimic other openstack projects, pep8, pylint, coverage 2011-08-31 14:41:36 -07:00