Forráskód Böngészése

fixing Pylint issues

ayush.goyal 4 éve
szülő
commit
be5d225afe
1 módosított fájl, 9 hozzáadás és 10 törlés
  1. 9 10
      desktop/core/src/desktop/lib/django_forms.py

+ 9 - 10
desktop/core/src/desktop/lib/django_forms.py

@@ -33,7 +33,6 @@ from django.forms.fields import MultiValueField, CharField, ChoiceField, Boolean
 from django.forms.widgets import MultiWidget, Select, TextInput, Textarea, HiddenInput, Input
 from django.forms.widgets import MultiWidget, Select, TextInput, Textarea, HiddenInput, Input
 from django.utils import formats
 from django.utils import formats
 from django.utils.safestring import mark_safe
 from django.utils.safestring import mark_safe
-from six import python_2_unicode_compatible
 
 
 import desktop.lib.i18n
 import desktop.lib.i18n
 from desktop.lib.i18n import smart_str
 from desktop.lib.i18n import smart_str
@@ -148,7 +147,7 @@ class ChoiceOrOtherWidget(MultiWidget):
   """
   """
   def __init__(self, attrs=None, choices=()):
   def __init__(self, attrs=None, choices=()):
     self.choices = choices
     self.choices = choices
-    self.values = [ val for pres, val in choices if val != OTHER_VAL ]
+    self.values = [val for pres, val in choices if val != OTHER_VAL]
     widgets = (
     widgets = (
       Select(attrs=attrs, choices=choices),
       Select(attrs=attrs, choices=choices),
       TextInput(attrs=attrs)
       TextInput(attrs=attrs)
@@ -165,13 +164,13 @@ class ChoiceOrOtherField(MultiValueField):
   def __init__(self, choices, initial=None, *args, **kwargs):
   def __init__(self, choices, initial=None, *args, **kwargs):
     assert not kwargs.get('required', False), "required=True is not supported"
     assert not kwargs.get('required', False), "required=True is not supported"
 
 
-    allchoices = [ x for x in choices ] # Force choices into a list.
-    allchoices.append( (OTHER_VAL, OTHER_PRES) )
+    allchoices = [x for x in choices] # Force choices into a list.
+    allchoices.append((OTHER_VAL, OTHER_PRES))
     self.widget = ChoiceOrOtherWidget(choices=allchoices)
     self.widget = ChoiceOrOtherWidget(choices=allchoices)
     choice_initial, other_initial = None, None
     choice_initial, other_initial = None, None
     if initial is not None:
     if initial is not None:
       # Match initial against one of the values
       # Match initial against one of the values
-      if initial in [ x for x, y in choices ]:
+      if initial in [x for x, y in choices]:
         choice_initial = initial
         choice_initial = initial
       else:
       else:
         choice_initial = OTHER_VAL
         choice_initial = OTHER_VAL
@@ -290,7 +289,7 @@ class MultiForm(object):
   def has_subform_data(self, subform_name, data):
   def has_subform_data(self, subform_name, data):
     """Test if data contains any information bound for the subform"""
     """Test if data contains any information bound for the subform"""
     prefix = self.add_prefix(subform_name)
     prefix = self.add_prefix(subform_name)
-    return len([ k.startswith(prefix) for k in list(data.keys()) ]) != 0
+    return len([k.startswith(prefix) for k in list(data.keys())]) != 0
 
 
   def add_subform(self, name, form_cls, data=None):
   def add_subform(self, name, form_cls, data=None):
     """Dynamically extend this MultiForm to include a new subform"""
     """Dynamically extend this MultiForm to include a new subform"""
@@ -358,7 +357,7 @@ class SubmitButton(Input):
 
 
 
 
 class ManagementForm(forms.Form):
 class ManagementForm(forms.Form):
-  add = BooleanField(widget=SubmitButton,required=False)
+  add = BooleanField(widget=SubmitButton, required=False)
   next_form_id = forms.IntegerField(widget=forms.HiddenInput, initial=0)
   next_form_id = forms.IntegerField(widget=forms.HiddenInput, initial=0)
 
 
   def __init__(self, add_label='+', *args, **kwargs):
   def __init__(self, add_label='+', *args, **kwargs):
@@ -383,7 +382,7 @@ class ManagementForm(forms.Form):
   def form_counts(self):
   def form_counts(self):
     """form_counts() -> The max number of forms, some could be non-existent (deleted)."""
     """form_counts() -> The max number of forms, some could be non-existent (deleted)."""
     try:
     try:
-      return int(self.data[ self.add_prefix('next_form_id') ])
+      return int(self.data[self.add_prefix('next_form_id')])
     except KeyError:
     except KeyError:
       return self.fields['next_form_id'].initial
       return self.fields['next_form_id'].initial
 
 
@@ -427,7 +426,7 @@ class BaseSimpleFormSet(StrAndUnicode):
       n_initial = self.initial and len(self.initial) or 0
       n_initial = self.initial and len(self.initial) or 0
       form = ManagementForm(prefix=self.prefix,
       form = ManagementForm(prefix=self.prefix,
                             add_label=self.add_label,
                             add_label=self.add_label,
-                            initial={ 'next_form_id': n_initial })
+                            initial={'next_form_id': n_initial})
     self.management_form = form
     self.management_form = form
 
 
   def empty_form(self):
   def empty_form(self):
@@ -550,7 +549,7 @@ class DependencyAwareForm(forms.Form):
       """Calculates data for single item."""
       """Calculates data for single item."""
       return self.add_prefix(cond), str(required_value), self.add_prefix(child)
       return self.add_prefix(cond), str(required_value), self.add_prefix(child)
 
 
-    return [ data(*x) for x in self.dependencies ]
+    return [data(*x) for x in self.dependencies]
 
 
   def render_dep_metadata(self):
   def render_dep_metadata(self):
     return urllib_quote_plus(json.dumps(self._calculate_data(), separators=(',', ':')))
     return urllib_quote_plus(json.dumps(self._calculate_data(), separators=(',', ':')))