fix flake8 bugbear errors

This commit is contained in:
David Lord 2023-01-18 10:31:08 -08:00
parent 8f13f5b6d6
commit 261e4a6cf2
No known key found for this signature in database
GPG key ID: 7A1C87E3F5BC42A8
3 changed files with 17 additions and 16 deletions

23
.flake8
View file

@ -1,12 +1,12 @@
[flake8]
# B = bugbear
# E = pycodestyle errors
# F = flake8 pyflakes
# W = pycodestyle warnings
# B9 = bugbear opinions
# ISC = implicit str concat
select = B, E, F, W, B9, ISC
ignore =
extend-select =
# bugbear
B
# bugbear opinions
B9
# implicit str concat
ISC
extend-ignore =
# slice notation whitespace, invalid
E203
# import at top, too many circular import fixes
@ -15,10 +15,11 @@ ignore =
E501
# bare except, handled by bugbear B001
E722
# bin op line break, invalid
W503
# requires Python 3.10
# zip with strict=, requires python >= 3.10
B905
# string formatting opinion, B028 renamed to B907
B028
B907
# up to 88 allowed by bugbear B950
max-line-length = 80
per-file-ignores =

View file

@ -120,14 +120,14 @@ def test_app_tearing_down_with_unhandled_exception(app, client):
@app.route("/")
def index():
raise Exception("dummy")
raise ValueError("dummy")
with pytest.raises(Exception, match="dummy"):
with pytest.raises(ValueError, match="dummy"):
with app.app_context():
client.get("/")
assert len(cleanup_stuff) == 1
assert isinstance(cleanup_stuff[0], Exception)
assert isinstance(cleanup_stuff[0], ValueError)
assert str(cleanup_stuff[0]) == "dummy"

View file

@ -1472,11 +1472,11 @@ def test_static_route_with_host_matching():
rv = flask.url_for("static", filename="index.html", _external=True)
assert rv == "http://example.com/static/index.html"
# Providing static_host without host_matching=True should error.
with pytest.raises(Exception):
with pytest.raises(AssertionError):
flask.Flask(__name__, static_host="example.com")
# Providing host_matching=True with static_folder
# but without static_host should error.
with pytest.raises(Exception):
with pytest.raises(AssertionError):
flask.Flask(__name__, host_matching=True)
# Providing host_matching=True without static_host
# but with static_folder=None should not error.