mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-08-20 14:29:51 -04:00
Do extra code style checks with flake8-bugbear
Flake8 Bugbear checks for some extra things that aren’t code style errors, but are likely to introduce bugs or unexpected behaviour. A good example is having mutable default function arguments, which get shared between every call to the function and therefore mutating a value in one place can unexpectedly cause it to change in another. This commit enables all the extra warnings provided by Flake8 Bugbear, except for the line length one (because we already lint for that separately). It disables: - _B003: Assigning to os.environ_ because I don’t really understand this - _B306: BaseException.message is removed in Python 3_ because I think our exceptions have a custom structure that means the `.message` attribute is still present
This commit is contained in:
@@ -25,13 +25,13 @@ def _test_permissions(
|
||||
usr,
|
||||
permissions,
|
||||
will_succeed,
|
||||
kwargs={}
|
||||
kwargs=None,
|
||||
):
|
||||
request.view_args.update({'service_id': 'foo'})
|
||||
if usr:
|
||||
client.login(usr)
|
||||
|
||||
decorator = user_has_permissions(*permissions, **kwargs)
|
||||
decorator = user_has_permissions(*permissions, **(kwargs or {}))
|
||||
decorated_index = decorator(index)
|
||||
|
||||
if will_succeed:
|
||||
@@ -462,7 +462,7 @@ def test_routes_have_permissions_decorators():
|
||||
'app/main/views/{}.py::{}\n'
|
||||
).format(file, function)
|
||||
|
||||
for endpoint, decorators in get_routes_and_decorators():
|
||||
for _endpoint, decorators in get_routes_and_decorators():
|
||||
|
||||
assert 'login_required' not in decorators, (
|
||||
'@login_required found\n'
|
||||
|
||||
Reference in New Issue
Block a user