From e5d09edc205d70ffc315b5f0ae687b356f0833b9 Mon Sep 17 00:00:00 2001 From: Akihiro Motoki Date: Tue, 15 Sep 2020 14:08:17 +0900 Subject: 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 --- openstack_auth/forms.py | 4 ++-- openstack_auth/tests/data_v3.py | 2 +- openstack_auth/tests/unit/test_auth.py | 2 +- openstack_auth/tests/unit/test_utils.py | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'openstack_auth') diff --git a/openstack_auth/forms.py b/openstack_auth/forms.py index b941e41ae..e49ff871d 100644 --- a/openstack_auth/forms.py +++ b/openstack_auth/forms.py @@ -77,7 +77,7 @@ class Login(django_auth_forms.AuthenticationForm): widget=forms.PasswordInput(render_value=False)) def __init__(self, *args, **kwargs): - super(Login, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) fields_ordering = ['username', 'password', 'region'] if settings.OPENSTACK_KEYSTONE_MULTIDOMAIN_SUPPORT: last_domain = self.request.COOKIES.get('login_domain', None) @@ -185,7 +185,7 @@ class DummyAuth(auth_plugin.BaseAuthPlugin): class Password(forms.Form): """Form used for changing user's password without having to log in.""" def __init__(self, *args, **kwargs): - super(Password, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields = collections.OrderedDict([ ( 'region', diff --git a/openstack_auth/tests/data_v3.py b/openstack_auth/tests/data_v3.py index ae1251429..f53f11ee2 100644 --- a/openstack_auth/tests/data_v3.py +++ b/openstack_auth/tests/data_v3.py @@ -37,7 +37,7 @@ class TestResponse(requests.Response): def __init__(self, data): self._text = None - super(TestResponse, self).__init__() + super().__init__() if isinstance(data, dict): self.status_code = data.get('status_code', 200) self.headers = data.get('headers', None) diff --git a/openstack_auth/tests/unit/test_auth.py b/openstack_auth/tests/unit/test_auth.py index 98c062d26..f4e7117aa 100644 --- a/openstack_auth/tests/unit/test_auth.py +++ b/openstack_auth/tests/unit/test_auth.py @@ -995,7 +995,7 @@ class OpenStackAuthTestsV3WithMock(test.TestCase): 'username': user.name} def setUp(self): - super(OpenStackAuthTestsV3WithMock, self).setUp() + super().setUp() if getattr(self, 'interface', None): override = self.settings(OPENSTACK_ENDPOINT_TYPE=self.interface) diff --git a/openstack_auth/tests/unit/test_utils.py b/openstack_auth/tests/unit/test_utils.py index ab91fdd01..59f1427bf 100644 --- a/openstack_auth/tests/unit/test_utils.py +++ b/openstack_auth/tests/unit/test_utils.py @@ -85,7 +85,7 @@ class UtilsTestCase(test.TestCase): class BehindProxyTestCase(test.TestCase): def setUp(self): - super(BehindProxyTestCase, self).setUp() + super().setUp() self.request = http.HttpRequest() def test_without_proxy(self): -- cgit v1.2.1