Skip to content

Commit e569cfa

Browse files
committed
Remove Python 2 code, clean up string concats, check other PR comments
1 parent 68017c2 commit e569cfa

File tree

7 files changed

+25
-23
lines changed

7 files changed

+25
-23
lines changed

CONTRIBUTING.rst

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,15 @@ Ready to contribute? Here's how to set up `django-bootstrap3` for local developm
7474

7575
Now you can make your changes locally.
7676

77-
5. When you're done making changes, check that your changes pass flake8 and the
78-
tests, including testing other Python versions with tox::
77+
5. When you're done making changes, apply reformat and check that your changes pass the tests::
7978

80-
$ flake8 bootstrap3 tests
81-
$ python setup.py test
82-
$ tox
79+
$ make reformat
80+
$ make test
81+
$ make tox
8382

84-
To get flake8 and tox, just pip install them into your virtualenv.
83+
See which commands are being run in Makefile. Note that `make test` runs on your local environment, and that `make tox` runs a separate virtualenv for all supported configurations.
84+
85+
The packages required for development are in `requirements.txt`.
8586

8687
6. Commit your changes and push your branch to GitHub::
8788

bootstrap3/components.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ def render_alert(content, alert_type=None, dismissable=True):
2626
css_classes = ["alert", "alert-" + text_value(alert_type)]
2727
if dismissable:
2828
css_classes.append("alert-dismissable")
29-
button = '<button type="button" class="close" ' + 'data-dismiss="alert" aria-hidden="true">&times;</button>'
29+
button = '<button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>'
3030
button_placeholder = "__BUTTON__"
3131
return mark_safe(
3232
render_tag(

bootstrap3/forms.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -106,12 +106,13 @@ def render_button(
106106
elif size == "md" or size == "medium":
107107
pass
108108
elif size:
109-
raise BootstrapError('Parameter "size" should be "xs", "sm", "lg" or ' + 'empty ("{}" given).'.format(size))
109+
raise BootstrapError('Parameter "size" should be "xs", "sm", "lg" or empty ("{}" given).'.format(size))
110110
if button_type:
111111
if button_type not in ("submit", "reset", "button", "link"):
112112
raise BootstrapError(
113-
'Parameter "button_type" should be "submit", "reset", '
114-
+ '"button", "link" or empty ("{}" given).'.format(button_type)
113+
'Parameter "button_type" should be "submit", "reset", "button", "link" or empty ("{}" given).'.format(
114+
button_type
115+
)
115116
)
116117
attrs["type"] = button_type
117118
classes = add_css_class(classes, extra_classes)

bootstrap3/renderers.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ def __init__(self, formset, *args, **kwargs):
9696
if not isinstance(formset, BaseFormSet):
9797
raise BootstrapError('Parameter "formset" should contain a valid Django Formset.')
9898
self.formset = formset
99-
super(FormsetRenderer, self).__init__(*args, **kwargs)
99+
super().__init__(*args, **kwargs)
100100

101101
def render_management_form(self):
102102
return text_value(self.formset.management_form)
@@ -150,7 +150,7 @@ def __init__(self, form, *args, **kwargs):
150150
if not isinstance(form, BaseForm):
151151
raise BootstrapError('Parameter "form" should contain a valid Django Form.')
152152
self.form = form
153-
super(FormRenderer, self).__init__(*args, **kwargs)
153+
super().__init__(*args, **kwargs)
154154
self.error_types = kwargs.get("error_types", "non_field_errors")
155155
self.error_css_class = kwargs.get("error_css_class", None)
156156
self.required_css_class = kwargs.get("required_css_class", None)
@@ -222,7 +222,7 @@ def __init__(self, field, *args, **kwargs):
222222
if not isinstance(field, BoundField):
223223
raise BootstrapError('Parameter "field" should contain a valid Django BoundField.')
224224
self.field = field
225-
super(FieldRenderer, self).__init__(*args, **kwargs)
225+
super().__init__(*args, **kwargs)
226226

227227
self.widget = field.field.widget
228228
self.is_multi_widget = isinstance(field.field.widget, MultiWidget)
@@ -508,7 +508,7 @@ def add_error_attrs(self):
508508
self.widget.attrs["title"] = field_title.strip()
509509

510510
def add_widget_attrs(self):
511-
super(InlineFieldRenderer, self).add_widget_attrs()
511+
super().add_widget_attrs()
512512
self.add_error_attrs()
513513

514514
def append_to_field(self, html):

bootstrap3/tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class SmallTestForm(forms.Form):
3232
)
3333

3434
def clean(self):
35-
cleaned_data = super(SmallTestForm, self).clean()
35+
cleaned_data = super().clean()
3636
raise forms.ValidationError("This error was added to show the non field errors styling.")
3737
return cleaned_data
3838

@@ -84,7 +84,7 @@ class TestForm(forms.Form):
8484
use_required_attribute = False
8585

8686
def clean(self):
87-
cleaned_data = super(TestForm, self).clean()
87+
cleaned_data = super().clean()
8888
raise forms.ValidationError("This error was added to show the non field errors styling.")
8989
return cleaned_data
9090

@@ -659,7 +659,7 @@ def test_button(self):
659659
res = render_template_with_form("{% bootstrap_button 'button' size='lg' href='#' %}")
660660
self.assertIn(
661661
res.strip(),
662-
'<a class="btn btn-default btn-lg" href="#">button</a><a href="#" ' + 'class="btn btn-lg">button</a>',
662+
'<a class="btn btn-default btn-lg" href="#">button</a><a href="#" class="btn btn-lg">button</a>',
663663
)
664664

665665

demo/demo/forms.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class ContactForm(TestForm):
1818

1919
class ContactBaseFormSet(BaseFormSet):
2020
def add_fields(self, form, index):
21-
super(ContactBaseFormSet, self).add_fields(form, index)
21+
super().add_fields(form, index)
2222

2323
def clean(self):
24-
super(ContactBaseFormSet, self).clean()
24+
super().clean()
2525
raise forms.ValidationError("This error was added to show the non form errors styling")
2626

2727

@@ -42,6 +42,6 @@ class ArticleForm(forms.Form):
4242
pub_date = forms.DateField()
4343

4444
def clean(self):
45-
cleaned_data = super(ArticleForm, self).clean()
45+
cleaned_data = super().clean()
4646
raise forms.ValidationError("This error was added to show the non field errors styling.")
4747
return cleaned_data

demo/demo/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class HomePageView(TemplateView):
2020
template_name = "demo/home.html"
2121

2222
def get_context_data(self, **kwargs):
23-
context = super(HomePageView, self).get_context_data(**kwargs)
23+
context = super().get_context_data(**kwargs)
2424
messages.info(self.request, "hello http://example.com")
2525
return context
2626

@@ -55,7 +55,7 @@ class FormWithFilesView(FormView):
5555
form_class = FilesForm
5656

5757
def get_context_data(self, **kwargs):
58-
context = super(FormWithFilesView, self).get_context_data(**kwargs)
58+
context = super().get_context_data(**kwargs)
5959
context["layout"] = self.request.GET.get("layout", "vertical")
6060
return context
6161

@@ -67,7 +67,7 @@ class PaginationView(TemplateView):
6767
template_name = "demo/pagination.html"
6868

6969
def get_context_data(self, **kwargs):
70-
context = super(PaginationView, self).get_context_data(**kwargs)
70+
context = super().get_context_data(**kwargs)
7171
lines = []
7272
for i in range(200):
7373
lines.append("Line %s" % (i + 1))

0 commit comments

Comments
 (0)