Skip to content

Commit 8dc9f53

Browse files
committed
Lint entire repo
1 parent 5ae6f94 commit 8dc9f53

8 files changed

+202
-217
lines changed

docs/conf.py

+9-12
Original file line numberDiff line numberDiff line change
@@ -17,41 +17,38 @@
1717

1818
# -- Project information -----------------------------------------------------
1919

20-
project = 'Flask-Babel'
21-
copyright = '2020, Armin Ronacher'
22-
author = 'Armin Ronacher'
20+
project = "Flask-Babel"
21+
copyright = "2020, Armin Ronacher"
22+
author = "Armin Ronacher"
2323

2424
# The full version, including alpha/beta/rc tags
25-
release = '4.0.0'
25+
release = "4.0.0"
2626

2727

2828
# -- General configuration ---------------------------------------------------
2929

3030
# Add any Sphinx extension module names here, as strings. They can be
3131
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3232
# ones.
33-
extensions = [
34-
'sphinx.ext.autodoc',
35-
'sphinx.ext.viewcode'
36-
]
33+
extensions = ["sphinx.ext.autodoc", "sphinx.ext.viewcode"]
3734

3835
# Add any paths that contain templates here, relative to this directory.
39-
templates_path = ['_templates']
36+
templates_path = ["_templates"]
4037

4138
# List of patterns, relative to source directory, that match files and
4239
# directories to ignore when looking for source files.
4340
# This pattern also affects html_static_path and html_extra_path.
44-
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
41+
exclude_patterns = ["_build", "Thumbs.db", ".DS_Store"]
4542

4643

4744
# -- Options for HTML output -------------------------------------------------
4845

4946
# The theme to use for HTML and HTML Help pages. See the documentation for
5047
# a list of builtin themes.
5148
#
52-
html_theme = 'furo'
49+
html_theme = "furo"
5350

5451
# Add any paths that contain custom static files (such as style sheets) here,
5552
# relative to this directory. They are copied after the builtin static files,
5653
# so a file named "default.css" will overwrite the builtin "default.css".
57-
html_static_path = ['_static']
54+
html_static_path = ["_static"]

tests/test_app_factory.py

+4-9
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,14 @@ def test_app_factory():
66
b = babel.Babel()
77

88
def locale_selector():
9-
return 'de_DE'
9+
return "de_DE"
1010

1111
def create_app():
1212
app_ = flask.Flask(__name__)
13-
b.init_app(
14-
app_,
15-
default_locale='en_US',
16-
locale_selector=locale_selector
17-
)
13+
b.init_app(app_, default_locale="en_US", locale_selector=locale_selector)
1814
return app_
1915

2016
app = create_app()
2117
with app.test_request_context():
22-
assert str(babel.get_locale()) == 'de_DE'
23-
assert babel.gettext(u'Hello %(name)s!', name='Peter') == \
24-
'Hallo Peter!'
18+
assert str(babel.get_locale()) == "de_DE"
19+
assert babel.gettext("Hello %(name)s!", name="Peter") == "Hallo Peter!"

tests/test_date_formatting.py

+24-26
Original file line numberDiff line numberDiff line change
@@ -13,46 +13,44 @@ def test_basics():
1313
delta = timedelta(days=6)
1414

1515
with app.test_request_context():
16-
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'
17-
assert babel.format_date(d) == 'Apr 12, 2010'
18-
assert babel.format_time(d) == '1:46:00\u202fPM'
19-
assert babel.format_timedelta(delta) == '1 week'
20-
assert babel.format_timedelta(delta, threshold=1) == '6 days'
16+
assert babel.format_datetime(d) == "Apr 12, 2010, 1:46:00\u202fPM"
17+
assert babel.format_date(d) == "Apr 12, 2010"
18+
assert babel.format_time(d) == "1:46:00\u202fPM"
19+
assert babel.format_timedelta(delta) == "1 week"
20+
assert babel.format_timedelta(delta, threshold=1) == "6 days"
2121

2222
with app.test_request_context():
23-
get_babel(app).default_timezone = 'Europe/Vienna'
24-
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00\u202fPM'
25-
assert babel.format_date(d) == 'Apr 12, 2010'
26-
assert babel.format_time(d) == '3:46:00\u202fPM'
23+
get_babel(app).default_timezone = "Europe/Vienna"
24+
assert babel.format_datetime(d) == "Apr 12, 2010, 3:46:00\u202fPM"
25+
assert babel.format_date(d) == "Apr 12, 2010"
26+
assert babel.format_time(d) == "3:46:00\u202fPM"
2727

2828
with app.test_request_context():
29-
get_babel(app).default_locale = 'de_DE'
30-
assert babel.format_datetime(d, 'long') == \
31-
'12. April 2010, 15:46:00 MESZ'
29+
get_babel(app).default_locale = "de_DE"
30+
assert babel.format_datetime(d, "long") == "12. April 2010, 15:46:00 MESZ"
3231

3332

3433
def test_custom_formats():
3534
app = flask.Flask(__name__)
3635
app.config.update(
37-
BABEL_DEFAULT_LOCALE='en_US',
38-
BABEL_DEFAULT_TIMEZONE='Pacific/Johnston'
36+
BABEL_DEFAULT_LOCALE="en_US", BABEL_DEFAULT_TIMEZONE="Pacific/Johnston"
3937
)
4038
b = babel.Babel(app)
41-
b.date_formats['datetime'] = 'long'
42-
b.date_formats['datetime.long'] = 'MMMM d, yyyy h:mm:ss a'
39+
b.date_formats["datetime"] = "long"
40+
b.date_formats["datetime.long"] = "MMMM d, yyyy h:mm:ss a"
4341
d = datetime(2010, 4, 12, 13, 46)
4442

4543
with app.test_request_context():
46-
assert babel.format_datetime(d) == 'April 12, 2010 3:46:00 AM'
44+
assert babel.format_datetime(d) == "April 12, 2010 3:46:00 AM"
4745

4846

4947
def test_custom_locale_selector():
5048
app = flask.Flask(__name__)
5149
b = babel.Babel(app)
5250
d = datetime(2010, 4, 12, 13, 46)
5351

54-
the_timezone = 'UTC'
55-
the_locale = 'en_US'
52+
the_timezone = "UTC"
53+
the_locale = "en_US"
5654

5755
def select_locale():
5856
return the_locale
@@ -64,21 +62,21 @@ def select_timezone():
6462
get_babel(app).timezone_selector = select_timezone
6563

6664
with app.test_request_context():
67-
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'
65+
assert babel.format_datetime(d) == "Apr 12, 2010, 1:46:00\u202fPM"
6866

69-
the_locale = 'de_DE'
70-
the_timezone = 'Europe/Vienna'
67+
the_locale = "de_DE"
68+
the_timezone = "Europe/Vienna"
7169

7270
with app.test_request_context():
73-
assert babel.format_datetime(d) == '12.04.2010, 15:46:00'
71+
assert babel.format_datetime(d) == "12.04.2010, 15:46:00"
7472

7573

7674
def test_refreshing():
7775
app = flask.Flask(__name__)
7876
babel.Babel(app)
7977
d = datetime(2010, 4, 12, 13, 46)
8078
with app.test_request_context():
81-
assert babel.format_datetime(d) == 'Apr 12, 2010, 1:46:00\u202fPM'
82-
get_babel(app).default_timezone = 'Europe/Vienna'
79+
assert babel.format_datetime(d) == "Apr 12, 2010, 1:46:00\u202fPM"
80+
get_babel(app).default_timezone = "Europe/Vienna"
8381
babel.refresh()
84-
assert babel.format_datetime(d) == 'Apr 12, 2010, 3:46:00\u202fPM'
82+
assert babel.format_datetime(d) == "Apr 12, 2010, 3:46:00\u202fPM"

tests/test_force_locale.py

+17-17
Original file line numberDiff line numberDiff line change
@@ -7,67 +7,67 @@
77

88
def test_force_locale():
99
app = flask.Flask(__name__)
10-
babel.Babel(app, locale_selector=lambda: 'de_DE')
10+
babel.Babel(app, locale_selector=lambda: "de_DE")
1111

1212
with app.test_request_context():
13-
assert str(babel.get_locale()) == 'de_DE'
14-
with babel.force_locale('en_US'):
15-
assert str(babel.get_locale()) == 'en_US'
16-
assert str(babel.get_locale()) == 'de_DE'
13+
assert str(babel.get_locale()) == "de_DE"
14+
with babel.force_locale("en_US"):
15+
assert str(babel.get_locale()) == "en_US"
16+
assert str(babel.get_locale()) == "de_DE"
1717

1818

1919
def test_force_locale_with_threading():
2020
app = flask.Flask(__name__)
21-
babel.Babel(app, locale_selector=lambda: 'de_DE')
21+
babel.Babel(app, locale_selector=lambda: "de_DE")
2222

2323
semaphore = Semaphore(value=0)
2424

2525
def first_request():
2626
with app.test_request_context():
27-
with babel.force_locale('en_US'):
28-
assert str(babel.get_locale()) == 'en_US'
27+
with babel.force_locale("en_US"):
28+
assert str(babel.get_locale()) == "en_US"
2929
semaphore.acquire()
3030

3131
thread = Thread(target=first_request)
3232
thread.start()
3333

3434
try:
3535
with app.test_request_context():
36-
assert str(babel.get_locale()) == 'de_DE'
36+
assert str(babel.get_locale()) == "de_DE"
3737
finally:
3838
semaphore.release()
3939
thread.join()
4040

4141

4242
def test_force_locale_with_threading_and_app_context():
4343
app = flask.Flask(__name__)
44-
babel.Babel(app, locale_selector=lambda: 'de_DE')
44+
babel.Babel(app, locale_selector=lambda: "de_DE")
4545

4646
semaphore = Semaphore(value=0)
4747

4848
def first_app_context():
4949
with app.app_context():
50-
with babel.force_locale('en_US'):
51-
assert str(babel.get_locale()) == 'en_US'
50+
with babel.force_locale("en_US"):
51+
assert str(babel.get_locale()) == "en_US"
5252
semaphore.acquire()
5353

5454
thread = Thread(target=first_app_context)
5555
thread.start()
5656

5757
try:
5858
with app.app_context():
59-
assert str(babel.get_locale()) == 'de_DE'
59+
assert str(babel.get_locale()) == "de_DE"
6060
finally:
6161
semaphore.release()
6262
thread.join()
6363

6464

6565
def test_refresh_during_force_locale():
6666
app = flask.Flask(__name__)
67-
babel.Babel(app, locale_selector=lambda: 'de_DE')
67+
babel.Babel(app, locale_selector=lambda: "de_DE")
6868

6969
with app.test_request_context():
70-
with babel.force_locale('en_US'):
71-
assert str(babel.get_locale()) == 'en_US'
70+
with babel.force_locale("en_US"):
71+
assert str(babel.get_locale()) == "en_US"
7272
babel.refresh()
73-
assert str(babel.get_locale()) == 'en_US'
73+
assert str(babel.get_locale()) == "en_US"

0 commit comments

Comments
 (0)