From 22a120d979250109eaa06a9c4515c0da025c7ef9 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 22 Jun 2022 19:45:06 -0700 Subject: [PATCH] *: pylint: Avoid calling super() with arguments Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/deluge/forms.py | 6 +++--- plinth/modules/networks/forms.py | 6 +++--- plinth/modules/pagekite/forms.py | 4 ++-- plinth/modules/pagekite/views.py | 2 +- plinth/modules/shadowsocks/forms.py | 2 +- plinth/modules/sharing/forms.py | 2 +- plinth/modules/sso/views.py | 7 +++---- plinth/modules/tor/forms.py | 2 +- plinth/modules/transmission/forms.py | 7 +++---- plinth/modules/users/forms.py | 12 ++++++------ plinth/modules/users/views.py | 16 ++++++++-------- plinth/package.py | 2 +- 12 files changed, 33 insertions(+), 35 deletions(-) diff --git a/plinth/modules/deluge/forms.py b/plinth/modules/deluge/forms.py index 825638204..195cfb158 100644 --- a/plinth/modules/deluge/forms.py +++ b/plinth/modules/deluge/forms.py @@ -17,6 +17,6 @@ class DelugeForm(DirectorySelectForm): def __init__(self, *args, **kw): validator = DirectoryValidator(username=SYSTEM_USER, check_creatable=True) - super(DelugeForm, self).__init__(title=_('Download directory'), - default='/var/lib/deluged/Downloads', - validator=validator, *args, **kw) + super().__init__(title=_('Download directory'), + default='/var/lib/deluged/Downloads', + validator=validator, *args, **kw) diff --git a/plinth/modules/networks/forms.py b/plinth/modules/networks/forms.py index 621efad99..20b9260c0 100644 --- a/plinth/modules/networks/forms.py +++ b/plinth/modules/networks/forms.py @@ -167,7 +167,7 @@ class GenericForm(ConnectionForm): def __init__(self, *args, **kwargs): """Initialize the form, populate interface choices.""" - super(GenericForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) choices = self._get_interface_choices(nm.DeviceType.GENERIC) self.fields['interface'].choices = choices @@ -183,7 +183,7 @@ class EthernetForm(ConnectionForm): def __init__(self, *args, **kwargs): """Initialize the form, populate interface choices.""" - super(EthernetForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) choices = self._get_interface_choices(nm.DeviceType.ETHERNET) self.fields['interface'].choices = choices @@ -278,7 +278,7 @@ requires clients to have the password to connect.'), def __init__(self, *args, **kwargs): """Initialize the form, populate interface choices.""" - super(WifiForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) choices = self._get_interface_choices(nm.DeviceType.WIFI) self.fields['interface'].choices = choices diff --git a/plinth/modules/pagekite/forms.py b/plinth/modules/pagekite/forms.py index ff1abf9af..a05c8a6b8 100644 --- a/plinth/modules/pagekite/forms.py +++ b/plinth/modules/pagekite/forms.py @@ -22,7 +22,7 @@ class TrimmedCharField(forms.CharField): if value: value = value.strip() - return super(TrimmedCharField, self).clean(value) + return super().clean(value) class ConfigurationForm(forms.Form): @@ -155,7 +155,7 @@ class AddCustomServiceForm(BaseCustomServiceForm): return match_found def clean(self): - cleaned_data = super(AddCustomServiceForm, self).clean() + cleaned_data = super().clean() try: is_predefined = self.matches_predefined_service(cleaned_data) except KeyError: diff --git a/plinth/modules/pagekite/views.py b/plinth/modules/pagekite/views.py index 02c8dfac4..b5307b9cd 100644 --- a/plinth/modules/pagekite/views.py +++ b/plinth/modules/pagekite/views.py @@ -62,4 +62,4 @@ class ConfigurationView(AppView): def form_valid(self, form): form.save(self.request) - return super(ConfigurationView, self).form_valid(form) + return super().form_valid(form) diff --git a/plinth/modules/shadowsocks/forms.py b/plinth/modules/shadowsocks/forms.py index 849c46fea..188e4caf5 100644 --- a/plinth/modules/shadowsocks/forms.py +++ b/plinth/modules/shadowsocks/forms.py @@ -29,7 +29,7 @@ class TrimmedCharField(forms.CharField): if value: value = value.strip() - return super(TrimmedCharField, self).clean(value) + return super().clean(value) class ShadowsocksForm(forms.Form): diff --git a/plinth/modules/sharing/forms.py b/plinth/modules/sharing/forms.py index b70782d12..e9a50a8c3 100644 --- a/plinth/modules/sharing/forms.py +++ b/plinth/modules/sharing/forms.py @@ -55,7 +55,7 @@ class AddShareForm(forms.Form): def clean(self): """Check that at least one group is added for non-public shares.""" - super(AddShareForm, self).clean() + super().clean() is_public = self.cleaned_data.get('is_public') groups = self.cleaned_data.get('groups') if not is_public and not groups: diff --git a/plinth/modules/sso/views.py b/plinth/modules/sso/views.py index 6415f545a..083d3eea7 100644 --- a/plinth/modules/sso/views.py +++ b/plinth/modules/sso/views.py @@ -53,7 +53,7 @@ class SSOLoginView(LoginView): form_class = AuthenticationForm def dispatch(self, request, *args, **kwargs): - response = super(SSOLoginView, self).dispatch(request, *args, **kwargs) + response = super().dispatch(request, *args, **kwargs) if request.user.is_authenticated: translation.set_language(request, response, request.user.userprofile.language) @@ -65,7 +65,7 @@ class SSOLoginView(LoginView): # axes_form_invalid when axes >= 5.0.0 becomes available in Debian stable. @axes_form_invalid def form_invalid(self, *args, **kwargs): - return super(SSOLoginView, self).form_invalid(*args, **kwargs) + return super().form_invalid(*args, **kwargs) class CaptchaLoginView(LoginView): @@ -74,8 +74,7 @@ class CaptchaLoginView(LoginView): form_class = CaptchaAuthenticationForm def dispatch(self, request, *args, **kwargs): - response = super(CaptchaLoginView, - self).dispatch(request, *args, **kwargs) + response = super().dispatch(request, *args, **kwargs) if not request.POST: return response diff --git a/plinth/modules/tor/forms.py b/plinth/modules/tor/forms.py index 08c67a38e..422456d68 100644 --- a/plinth/modules/tor/forms.py +++ b/plinth/modules/tor/forms.py @@ -24,7 +24,7 @@ class TrimmedCharField(forms.CharField): value = value.strip() value = value.replace('\r\n', '\n') - return super(TrimmedCharField, self).clean(value) + return super().clean(value) def bridges_validator(bridges): diff --git a/plinth/modules/transmission/forms.py b/plinth/modules/transmission/forms.py index 4bac74885..5fcf869b4 100644 --- a/plinth/modules/transmission/forms.py +++ b/plinth/modules/transmission/forms.py @@ -17,7 +17,6 @@ class TransmissionForm(DirectorySelectForm): def __init__(self, *args, **kw): validator = DirectoryValidator(username=SYSTEM_USER, check_creatable=True) - super(TransmissionForm, - self).__init__(title=_('Download directory'), - default='/var/lib/transmission-daemon/downloads', - validator=validator, *args, **kw) + super().__init__(title=_('Download directory'), + default='/var/lib/transmission-daemon/downloads', + validator=validator, *args, **kw) diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index 61814b5c5..5dd6b7a74 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -125,7 +125,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin, def __init__(self, request, *args, **kwargs): """Initialize the form with extra request argument.""" self.request = request - super(CreateUserForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['username'].widget.attrs.update({ 'autofocus': 'autofocus', 'autocapitalize': 'none', @@ -134,7 +134,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin, def save(self, commit=True): """Save the user model and create LDAP user if required.""" - user = super(CreateUserForm, self).save(commit) + user = super().save(commit) if commit: user.userprofile.language = self.cleaned_data['language'] @@ -206,7 +206,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm, self.request = request self.username = username - super(UserUpdateForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.is_last_admin_user = get_last_admin_user() == self.username self.fields['username'].widget.attrs.update({ 'autofocus': 'autofocus', @@ -243,7 +243,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm, def save(self, commit=True): """Update LDAP user name and groups after saving user model.""" - user = super(UserUpdateForm, self).save(commit=False) + user = super().save(commit=False) # Profile is auto saved with user object user.userprofile.language = self.cleaned_data['language'] auth_username = self.request.user.username @@ -348,13 +348,13 @@ class UserChangePasswordForm(PasswordConfirmForm, SetPasswordForm): def __init__(self, request, *args, **kwargs): """Initialize the form with extra request argument.""" self.request = request - super(UserChangePasswordForm, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.fields['new_password1'].widget.attrs.update( {'autofocus': 'autofocus'}) def save(self, commit=True): """Save the user model and change LDAP password as well.""" - user = super(UserChangePasswordForm, self).save(commit) + user = super().save(commit) auth_username = self.request.user.username if commit: process_input = '{0}\n{1}'.format( diff --git a/plinth/modules/users/views.py b/plinth/modules/users/views.py index ede8e0add..7d25fe518 100644 --- a/plinth/modules/users/views.py +++ b/plinth/modules/users/views.py @@ -29,7 +29,7 @@ class ContextMixin: def get_context_data(self, **kwargs): """Add self.title to template context.""" - context = super(ContextMixin, self).get_context_data(**kwargs) + context = super().get_context_data(**kwargs) context['title'] = getattr(self, 'title', '') return context @@ -45,7 +45,7 @@ class UserCreate(ContextMixin, SuccessMessageMixin, CreateView): def get_form_kwargs(self): """Make the request object available to the form.""" - kwargs = super(UserCreate, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['request'] = self.request return kwargs @@ -62,7 +62,7 @@ class UserList(AppView, ContextMixin, django.views.generic.ListView): app_id = 'users' def get_context_data(self, *args, **kwargs): - context = super(UserList, self).get_context_data(*args, **kwargs) + context = super().get_context_data(*args, **kwargs) context['last_admin_user'] = get_last_admin_user() return context @@ -86,14 +86,14 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView): def get_form_kwargs(self): """Make the request object available to the form.""" - kwargs = super(UserUpdate, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['request'] = self.request kwargs['username'] = self.object.username return kwargs def get_initial(self): """Return the data for initial form load.""" - initial = super(UserUpdate, self).get_initial() + initial = super().get_initial() try: ssh_keys = actions.superuser_run( 'ssh', ['get-keys', '--username', self.object.username]) @@ -190,7 +190,7 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView): def get_form_kwargs(self): """Make the user object available to the form.""" - kwargs = super(UserChangePassword, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['request'] = self.request kwargs['user'] = User.objects.get(username=self.kwargs['slug']) return kwargs @@ -209,7 +209,7 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView): """ form.save() update_session_auth_hash(self.request, form.user) - return super(UserChangePassword, self).form_valid(form) + return super().form_valid(form) class FirstBootView(django.views.generic.CreateView): @@ -238,7 +238,7 @@ class FirstBootView(django.views.generic.CreateView): def get_form_kwargs(self): """Make request available to the form (to insert messages)""" - kwargs = super(FirstBootView, self).get_form_kwargs() + kwargs = super().get_form_kwargs() kwargs['request'] = self.request return kwargs diff --git a/plinth/package.py b/plinth/package.py index 9ae39d9a2..315b514b6 100644 --- a/plinth/package.py +++ b/plinth/package.py @@ -241,7 +241,7 @@ class PackageException(Exception): def __init__(self, error_string=None, error_details=None, *args, **kwargs): """Store apt-get error string and details.""" - super(PackageException, self).__init__(*args, **kwargs) + super().__init__(*args, **kwargs) self.error_string = error_string self.error_details = error_details