Skip to content

Commit 66a44ff

Browse files
authored
Merge pull request #382 from PanderMusubi/linters
lint improvements for comments whitespace, import order, is None and …
2 parents 770e62c + 83263a9 commit 66a44ff

File tree

10 files changed

+37
-23
lines changed

10 files changed

+37
-23
lines changed

examples/bootstrap4/app.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from flask_wtf import FlaskForm, CSRFProtect
66
from wtforms.validators import DataRequired, Length, Regexp
77
from wtforms.fields import *
8-
from flask_bootstrap import Bootstrap4, SwitchField
98
from flask_sqlalchemy import SQLAlchemy
9+
from flask_bootstrap import Bootstrap4, SwitchField
1010

1111
app = Flask(__name__)
1212
app.secret_key = 'dev'
@@ -34,6 +34,7 @@
3434

3535
class ExampleForm(FlaskForm):
3636
"""An example form that contains all the supported bootstrap style form fields."""
37+
3738
date = DateField(description="We'll never share your email with anyone else.") # add help text with `description`
3839
datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw`
3940
datetime_local = DateTimeLocalField()
@@ -52,8 +53,8 @@ class ExampleForm(FlaskForm):
5253
select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
5354
select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
5455
bio = TextAreaField()
55-
search = SearchField() # will autocapitalize on mobile
56-
title = StringField() # will not autocapitalize on mobile
56+
search = SearchField() # will autocapitalize on mobile
57+
title = StringField() # will not autocapitalize on mobile
5758
secret = PasswordField()
5859
remember = BooleanField('Remember me')
5960
submit = SubmitField()
@@ -96,7 +97,8 @@ class ContactForm(FlaskForm):
9697

9798
class BootswatchForm(FlaskForm):
9899
"""Form to test Bootswatch."""
99-
#DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
100+
101+
# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
100102
theme_name = RadioField(
101103
default='default',
102104
choices=[
@@ -208,7 +210,7 @@ def test_bootswatch():
208210
app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data
209211
flash(f'Render style has been set to {form.theme_name.data}.')
210212
else:
211-
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None:
213+
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None:
212214
form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME']
213215
return render_template('bootswatch.html', form=form)
214216

examples/bootstrap5/app.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
from flask_wtf import FlaskForm, CSRFProtect
66
from wtforms.validators import DataRequired, Length, Regexp
77
from wtforms.fields import *
8-
from flask_bootstrap import Bootstrap5, SwitchField
98
from flask_sqlalchemy import SQLAlchemy
9+
from flask_bootstrap import Bootstrap5, SwitchField
1010

1111
app = Flask(__name__)
1212
app.secret_key = 'dev'
@@ -34,6 +34,7 @@
3434

3535
class ExampleForm(FlaskForm):
3636
"""An example form that contains all the supported bootstrap style form fields."""
37+
3738
date = DateField(description="We'll never share your email with anyone else.") # add help text with `description`
3839
datetime = DateTimeField(render_kw={'placeholder': 'this is a placeholder'}) # add HTML attribute with `render_kw`
3940
datetime_local = DateTimeLocalField()
@@ -52,8 +53,8 @@ class ExampleForm(FlaskForm):
5253
select = SelectField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
5354
select_multiple = SelectMultipleField(choices=[('dog', 'Dog'), ('cat', 'Cat'), ('bird', 'Bird'), ('alien', 'Alien')])
5455
bio = TextAreaField()
55-
search = SearchField() # will autocapitalize on mobile
56-
title = StringField() # will not autocapitalize on mobile
56+
search = SearchField() # will autocapitalize on mobile
57+
title = StringField() # will not autocapitalize on mobile
5758
secret = PasswordField()
5859
remember = BooleanField('Remember me')
5960
submit = SubmitField()
@@ -96,7 +97,8 @@ class ContactForm(FlaskForm):
9697

9798
class BootswatchForm(FlaskForm):
9899
"""Form to test Bootswatch."""
99-
#DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
100+
101+
# DO NOT EDIT! Use list-bootswatch.py to generate the Radiofield below.
100102
theme_name = RadioField(
101103
default='default',
102104
choices=[
@@ -212,7 +214,7 @@ def test_bootswatch():
212214
app.config['BOOTSTRAP_BOOTSWATCH_THEME'] = form.theme_name.data
213215
flash(f'Render style has been set to {form.theme_name.data}.')
214216
else:
215-
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] != None:
217+
if app.config['BOOTSTRAP_BOOTSWATCH_THEME'] is not None:
216218
form.theme_name.data = app.config['BOOTSTRAP_BOOTSWATCH_THEME']
217219
return render_template('bootswatch.html', form=form)
218220

flask_bootstrap/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ def create_app():
239239
.. versionchanged:: 2.0.0
240240
Move common logic to base class ``_Bootstrap``.
241241
"""
242+
242243
bootstrap_version = '4.6.1'
243244
jquery_version = '3.5.1'
244245
popper_version = '1.16.1'
@@ -276,6 +277,7 @@ def create_app():
276277
277278
.. versionadded:: 2.0.0
278279
"""
280+
279281
bootstrap_version = '5.3.2'
280282
popper_version = '2.11.8'
281283
icons_version = '1.11.3'

tests/test_bootstrap4/test_bootstrap.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,11 @@ def test_deprecate_bootstrap_class(self):
1515

1616
app = Flask(__name__)
1717
with pytest.warns(UserWarning):
18-
bootstrap = Bootstrap(app) # noqa: F841
18+
_ = Bootstrap(app)
1919

2020
def test_deprecate_bootstrap_template_path(self, app, client):
2121
@app.route('/test')
22-
def foo():
22+
def test_render_template_string():
2323
return render_template_string('''
2424
{% from 'bootstrap/utils.html' import render_icon %}
2525
{{ render_icon('heart') }}

tests/test_bootstrap4/test_render_breadcrumb_item.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
def test_render_breadcrumb_item_active(app, client):
55
@app.route('/not_active_item')
6-
def foo():
6+
def item_foo():
77
return render_template_string('''
88
{% from 'bootstrap4/nav.html' import render_breadcrumb_item %}
9-
{{ render_breadcrumb_item('bar', 'Bar') }}
9+
{{ render_breadcrumb_item('item_bar', 'Bar') }}
1010
''')
1111

1212
@app.route('/active_item')
13-
def bar():
13+
def item_bar():
1414
return render_template_string('''
1515
{% from 'bootstrap4/nav.html' import render_breadcrumb_item %}
16-
{{ render_breadcrumb_item('bar', 'Bar') }}
16+
{{ render_breadcrumb_item('item_bar', 'Bar') }}
1717
''')
1818

1919
response = client.get('/not_active_item')

tests/test_bootstrap4/test_render_icon.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,10 +154,18 @@ def test_render_icon_font_config(app, client):
154154
def icon():
155155
return render_template_string('''
156156
{% from 'bootstrap4/utils.html' import render_icon %}
157+
{{ bootstrap.load_icon_font_css() }}
157158
{{ render_icon('heart', font=True) }}
158159
''')
159160

160161
response = client.get('/icon')
161162
data = response.get_data(as_text=True)
162163
assert 'size: 100;' in data
163164
assert 'text-success' in data
165+
166+
# complete test coverage for bootstrap.load_icon_font_css()
167+
app.config['BOOTSTRAP_SERVE_LOCAL'] = not app.config['BOOTSTRAP_SERVE_LOCAL']
168+
response = client.get('/icon')
169+
data = response.get_data(as_text=True)
170+
assert 'size: 100;' in data
171+
assert 'text-success' in data

tests/test_bootstrap4/test_render_nav_item.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33

44
def test_render_nav_item_active(app, client):
55
@app.route('/active')
6-
def foo():
6+
def item_foo():
77
return render_template_string('''
88
{% from 'bootstrap4/nav.html' import render_nav_item %}
9-
{{ render_nav_item('foo', 'Foo') }}
9+
{{ render_nav_item('item_foo', 'Foo') }}
1010
''')
1111

1212
@app.route('/not_active')
13-
def bar():
13+
def item_bar():
1414
return render_template_string('''
1515
{% from 'bootstrap4/nav.html' import render_nav_item %}
16-
{{ render_nav_item('foo', 'Foo') }}
16+
{{ render_nav_item('item_foo', 'Foo') }}
1717
''')
1818

1919
response = client.get('/active')

tests/test_bootstrap4/test_render_pager.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Message(db.Model):
1212
def test():
1313
db.drop_all()
1414
db.create_all()
15-
for i in range(100):
15+
for _ in range(100):
1616
msg = Message()
1717
db.session.add(msg)
1818
db.session.commit()

tests/test_bootstrap4/test_render_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Message(db.Model):
1212
def test():
1313
db.drop_all()
1414
db.create_all()
15-
for i in range(100): # noqa: F841
15+
for _ in range(100):
1616
msg = Message()
1717
db.session.add(msg)
1818
db.session.commit()

tests/test_bootstrap5/test_pagination.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class Message(db.Model):
1212
def test():
1313
db.drop_all()
1414
db.create_all()
15-
for i in range(100): # noqa: F841
15+
for _ in range(100):
1616
msg = Message()
1717
db.session.add(msg)
1818
db.session.commit()

0 commit comments

Comments
 (0)