mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-09-19 04:59:01 +00:00
*: pylint: Avoid calling super() with arguments
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
bfa11beb73
commit
22a120d979
@ -17,6 +17,6 @@ class DelugeForm(DirectorySelectForm):
|
|||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
validator = DirectoryValidator(username=SYSTEM_USER,
|
validator = DirectoryValidator(username=SYSTEM_USER,
|
||||||
check_creatable=True)
|
check_creatable=True)
|
||||||
super(DelugeForm, self).__init__(title=_('Download directory'),
|
super().__init__(title=_('Download directory'),
|
||||||
default='/var/lib/deluged/Downloads',
|
default='/var/lib/deluged/Downloads',
|
||||||
validator=validator, *args, **kw)
|
validator=validator, *args, **kw)
|
||||||
|
|||||||
@ -167,7 +167,7 @@ class GenericForm(ConnectionForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize the form, populate interface choices."""
|
"""Initialize the form, populate interface choices."""
|
||||||
super(GenericForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
choices = self._get_interface_choices(nm.DeviceType.GENERIC)
|
choices = self._get_interface_choices(nm.DeviceType.GENERIC)
|
||||||
self.fields['interface'].choices = choices
|
self.fields['interface'].choices = choices
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ class EthernetForm(ConnectionForm):
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize the form, populate interface choices."""
|
"""Initialize the form, populate interface choices."""
|
||||||
super(EthernetForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
choices = self._get_interface_choices(nm.DeviceType.ETHERNET)
|
choices = self._get_interface_choices(nm.DeviceType.ETHERNET)
|
||||||
self.fields['interface'].choices = choices
|
self.fields['interface'].choices = choices
|
||||||
|
|
||||||
@ -278,7 +278,7 @@ requires clients to have the password to connect.'),
|
|||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
def __init__(self, *args, **kwargs):
|
||||||
"""Initialize the form, populate interface choices."""
|
"""Initialize the form, populate interface choices."""
|
||||||
super(WifiForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
choices = self._get_interface_choices(nm.DeviceType.WIFI)
|
choices = self._get_interface_choices(nm.DeviceType.WIFI)
|
||||||
self.fields['interface'].choices = choices
|
self.fields['interface'].choices = choices
|
||||||
|
|
||||||
|
|||||||
@ -22,7 +22,7 @@ class TrimmedCharField(forms.CharField):
|
|||||||
if value:
|
if value:
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
|
|
||||||
return super(TrimmedCharField, self).clean(value)
|
return super().clean(value)
|
||||||
|
|
||||||
|
|
||||||
class ConfigurationForm(forms.Form):
|
class ConfigurationForm(forms.Form):
|
||||||
@ -155,7 +155,7 @@ class AddCustomServiceForm(BaseCustomServiceForm):
|
|||||||
return match_found
|
return match_found
|
||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
cleaned_data = super(AddCustomServiceForm, self).clean()
|
cleaned_data = super().clean()
|
||||||
try:
|
try:
|
||||||
is_predefined = self.matches_predefined_service(cleaned_data)
|
is_predefined = self.matches_predefined_service(cleaned_data)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|||||||
@ -62,4 +62,4 @@ class ConfigurationView(AppView):
|
|||||||
|
|
||||||
def form_valid(self, form):
|
def form_valid(self, form):
|
||||||
form.save(self.request)
|
form.save(self.request)
|
||||||
return super(ConfigurationView, self).form_valid(form)
|
return super().form_valid(form)
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class TrimmedCharField(forms.CharField):
|
|||||||
if value:
|
if value:
|
||||||
value = value.strip()
|
value = value.strip()
|
||||||
|
|
||||||
return super(TrimmedCharField, self).clean(value)
|
return super().clean(value)
|
||||||
|
|
||||||
|
|
||||||
class ShadowsocksForm(forms.Form):
|
class ShadowsocksForm(forms.Form):
|
||||||
|
|||||||
@ -55,7 +55,7 @@ class AddShareForm(forms.Form):
|
|||||||
|
|
||||||
def clean(self):
|
def clean(self):
|
||||||
"""Check that at least one group is added for non-public shares."""
|
"""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')
|
is_public = self.cleaned_data.get('is_public')
|
||||||
groups = self.cleaned_data.get('groups')
|
groups = self.cleaned_data.get('groups')
|
||||||
if not is_public and not groups:
|
if not is_public and not groups:
|
||||||
|
|||||||
@ -53,7 +53,7 @@ class SSOLoginView(LoginView):
|
|||||||
form_class = AuthenticationForm
|
form_class = AuthenticationForm
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
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:
|
if request.user.is_authenticated:
|
||||||
translation.set_language(request, response,
|
translation.set_language(request, response,
|
||||||
request.user.userprofile.language)
|
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 when axes >= 5.0.0 becomes available in Debian stable.
|
||||||
@axes_form_invalid
|
@axes_form_invalid
|
||||||
def form_invalid(self, *args, **kwargs):
|
def form_invalid(self, *args, **kwargs):
|
||||||
return super(SSOLoginView, self).form_invalid(*args, **kwargs)
|
return super().form_invalid(*args, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
class CaptchaLoginView(LoginView):
|
class CaptchaLoginView(LoginView):
|
||||||
@ -74,8 +74,7 @@ class CaptchaLoginView(LoginView):
|
|||||||
form_class = CaptchaAuthenticationForm
|
form_class = CaptchaAuthenticationForm
|
||||||
|
|
||||||
def dispatch(self, request, *args, **kwargs):
|
def dispatch(self, request, *args, **kwargs):
|
||||||
response = super(CaptchaLoginView,
|
response = super().dispatch(request, *args, **kwargs)
|
||||||
self).dispatch(request, *args, **kwargs)
|
|
||||||
if not request.POST:
|
if not request.POST:
|
||||||
return response
|
return response
|
||||||
|
|
||||||
|
|||||||
@ -24,7 +24,7 @@ class TrimmedCharField(forms.CharField):
|
|||||||
value = value.strip()
|
value = value.strip()
|
||||||
value = value.replace('\r\n', '\n')
|
value = value.replace('\r\n', '\n')
|
||||||
|
|
||||||
return super(TrimmedCharField, self).clean(value)
|
return super().clean(value)
|
||||||
|
|
||||||
|
|
||||||
def bridges_validator(bridges):
|
def bridges_validator(bridges):
|
||||||
|
|||||||
@ -17,7 +17,6 @@ class TransmissionForm(DirectorySelectForm):
|
|||||||
def __init__(self, *args, **kw):
|
def __init__(self, *args, **kw):
|
||||||
validator = DirectoryValidator(username=SYSTEM_USER,
|
validator = DirectoryValidator(username=SYSTEM_USER,
|
||||||
check_creatable=True)
|
check_creatable=True)
|
||||||
super(TransmissionForm,
|
super().__init__(title=_('Download directory'),
|
||||||
self).__init__(title=_('Download directory'),
|
default='/var/lib/transmission-daemon/downloads',
|
||||||
default='/var/lib/transmission-daemon/downloads',
|
validator=validator, *args, **kw)
|
||||||
validator=validator, *args, **kw)
|
|
||||||
|
|||||||
@ -125,7 +125,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin,
|
|||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
"""Initialize the form with extra request argument."""
|
"""Initialize the form with extra request argument."""
|
||||||
self.request = request
|
self.request = request
|
||||||
super(CreateUserForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['username'].widget.attrs.update({
|
self.fields['username'].widget.attrs.update({
|
||||||
'autofocus': 'autofocus',
|
'autofocus': 'autofocus',
|
||||||
'autocapitalize': 'none',
|
'autocapitalize': 'none',
|
||||||
@ -134,7 +134,7 @@ class CreateUserForm(ValidNewUsernameCheckMixin,
|
|||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
"""Save the user model and create LDAP user if required."""
|
"""Save the user model and create LDAP user if required."""
|
||||||
user = super(CreateUserForm, self).save(commit)
|
user = super().save(commit)
|
||||||
|
|
||||||
if commit:
|
if commit:
|
||||||
user.userprofile.language = self.cleaned_data['language']
|
user.userprofile.language = self.cleaned_data['language']
|
||||||
@ -206,7 +206,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm,
|
|||||||
|
|
||||||
self.request = request
|
self.request = request
|
||||||
self.username = username
|
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.is_last_admin_user = get_last_admin_user() == self.username
|
||||||
self.fields['username'].widget.attrs.update({
|
self.fields['username'].widget.attrs.update({
|
||||||
'autofocus': 'autofocus',
|
'autofocus': 'autofocus',
|
||||||
@ -243,7 +243,7 @@ class UserUpdateForm(ValidNewUsernameCheckMixin, PasswordConfirmForm,
|
|||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
"""Update LDAP user name and groups after saving user model."""
|
"""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
|
# Profile is auto saved with user object
|
||||||
user.userprofile.language = self.cleaned_data['language']
|
user.userprofile.language = self.cleaned_data['language']
|
||||||
auth_username = self.request.user.username
|
auth_username = self.request.user.username
|
||||||
@ -348,13 +348,13 @@ class UserChangePasswordForm(PasswordConfirmForm, SetPasswordForm):
|
|||||||
def __init__(self, request, *args, **kwargs):
|
def __init__(self, request, *args, **kwargs):
|
||||||
"""Initialize the form with extra request argument."""
|
"""Initialize the form with extra request argument."""
|
||||||
self.request = request
|
self.request = request
|
||||||
super(UserChangePasswordForm, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self.fields['new_password1'].widget.attrs.update(
|
self.fields['new_password1'].widget.attrs.update(
|
||||||
{'autofocus': 'autofocus'})
|
{'autofocus': 'autofocus'})
|
||||||
|
|
||||||
def save(self, commit=True):
|
def save(self, commit=True):
|
||||||
"""Save the user model and change LDAP password as well."""
|
"""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
|
auth_username = self.request.user.username
|
||||||
if commit:
|
if commit:
|
||||||
process_input = '{0}\n{1}'.format(
|
process_input = '{0}\n{1}'.format(
|
||||||
|
|||||||
@ -29,7 +29,7 @@ class ContextMixin:
|
|||||||
|
|
||||||
def get_context_data(self, **kwargs):
|
def get_context_data(self, **kwargs):
|
||||||
"""Add self.title to template context."""
|
"""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', '')
|
context['title'] = getattr(self, 'title', '')
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ class UserCreate(ContextMixin, SuccessMessageMixin, CreateView):
|
|||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Make the request object available to the form."""
|
"""Make the request object available to the form."""
|
||||||
kwargs = super(UserCreate, self).get_form_kwargs()
|
kwargs = super().get_form_kwargs()
|
||||||
kwargs['request'] = self.request
|
kwargs['request'] = self.request
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
@ -62,7 +62,7 @@ class UserList(AppView, ContextMixin, django.views.generic.ListView):
|
|||||||
app_id = 'users'
|
app_id = 'users'
|
||||||
|
|
||||||
def get_context_data(self, *args, **kwargs):
|
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()
|
context['last_admin_user'] = get_last_admin_user()
|
||||||
return context
|
return context
|
||||||
|
|
||||||
@ -86,14 +86,14 @@ class UserUpdate(ContextMixin, SuccessMessageMixin, UpdateView):
|
|||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Make the request object available to the form."""
|
"""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['request'] = self.request
|
||||||
kwargs['username'] = self.object.username
|
kwargs['username'] = self.object.username
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
def get_initial(self):
|
def get_initial(self):
|
||||||
"""Return the data for initial form load."""
|
"""Return the data for initial form load."""
|
||||||
initial = super(UserUpdate, self).get_initial()
|
initial = super().get_initial()
|
||||||
try:
|
try:
|
||||||
ssh_keys = actions.superuser_run(
|
ssh_keys = actions.superuser_run(
|
||||||
'ssh', ['get-keys', '--username', self.object.username])
|
'ssh', ['get-keys', '--username', self.object.username])
|
||||||
@ -190,7 +190,7 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
|
|||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Make the user object available to the form."""
|
"""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['request'] = self.request
|
||||||
kwargs['user'] = User.objects.get(username=self.kwargs['slug'])
|
kwargs['user'] = User.objects.get(username=self.kwargs['slug'])
|
||||||
return kwargs
|
return kwargs
|
||||||
@ -209,7 +209,7 @@ class UserChangePassword(ContextMixin, SuccessMessageMixin, FormView):
|
|||||||
"""
|
"""
|
||||||
form.save()
|
form.save()
|
||||||
update_session_auth_hash(self.request, form.user)
|
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):
|
class FirstBootView(django.views.generic.CreateView):
|
||||||
@ -238,7 +238,7 @@ class FirstBootView(django.views.generic.CreateView):
|
|||||||
|
|
||||||
def get_form_kwargs(self):
|
def get_form_kwargs(self):
|
||||||
"""Make request available to the form (to insert messages)"""
|
"""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
|
kwargs['request'] = self.request
|
||||||
return kwargs
|
return kwargs
|
||||||
|
|
||||||
|
|||||||
@ -241,7 +241,7 @@ class PackageException(Exception):
|
|||||||
|
|
||||||
def __init__(self, error_string=None, error_details=None, *args, **kwargs):
|
def __init__(self, error_string=None, error_details=None, *args, **kwargs):
|
||||||
"""Store apt-get error string and details."""
|
"""Store apt-get error string and details."""
|
||||||
super(PackageException, self).__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
|
|
||||||
self.error_string = error_string
|
self.error_string = error_string
|
||||||
self.error_details = error_details
|
self.error_details = error_details
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user