mirror of
https://github.com/GSA/notifications-api.git
synced 2026-05-05 00:30:04 -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) - B903 Data class should either be immutable or use `__slots__` because this seems to false-positive on some of our custom exceptions - B902 Invalid first argument 'cls' used for instance method because some SQLAlchemy decorators (eg `declared_attr`) make things that aren’t formally class methods take a class not an instance as their first argument It disables: - _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 Matches the work done in other repos: - https://github.com/alphagov/notifications-admin/pull/3172/files
This commit is contained in:
@@ -107,7 +107,7 @@ def create_service(
|
||||
service_id=None,
|
||||
restricted=False,
|
||||
count_as_live=True,
|
||||
service_permissions=[EMAIL_TYPE, SMS_TYPE],
|
||||
service_permissions=None,
|
||||
research_mode=False,
|
||||
active=True,
|
||||
email_from=None,
|
||||
@@ -136,7 +136,12 @@ def create_service(
|
||||
go_live_at=go_live_at,
|
||||
crown=crown
|
||||
)
|
||||
dao_create_service(service, service.created_by, service_id, service_permissions=service_permissions)
|
||||
dao_create_service(
|
||||
service,
|
||||
service.created_by,
|
||||
service_id,
|
||||
service_permissions=service_permissions,
|
||||
)
|
||||
|
||||
service.active = active
|
||||
service.research_mode = research_mode
|
||||
@@ -666,12 +671,12 @@ def create_invited_org_user(organisation, invited_by, email_address='invite@exam
|
||||
return invited_org_user
|
||||
|
||||
|
||||
def create_daily_sorted_letter(billing_day=date(2018, 1, 18),
|
||||
def create_daily_sorted_letter(billing_day=None,
|
||||
file_name="Notify-20180118123.rs.txt",
|
||||
unsorted_count=0,
|
||||
sorted_count=0):
|
||||
daily_sorted_letter = DailySortedLetter(
|
||||
billing_day=billing_day,
|
||||
billing_day=billing_day or date(2018, 1, 18),
|
||||
file_name=file_name,
|
||||
unsorted_count=unsorted_count,
|
||||
sorted_count=sorted_count
|
||||
@@ -1007,22 +1012,22 @@ def create_service_contact_list(
|
||||
def create_broadcast_message(
|
||||
template,
|
||||
created_by=None,
|
||||
personalisation={},
|
||||
personalisation=None,
|
||||
status=BroadcastStatusType.DRAFT,
|
||||
starts_at=None,
|
||||
finishes_at=None,
|
||||
areas={},
|
||||
areas=None,
|
||||
):
|
||||
broadcast_message = BroadcastMessage(
|
||||
service_id=template.service_id,
|
||||
template_id=template.id,
|
||||
template_version=template.version,
|
||||
personalisation=personalisation,
|
||||
personalisation=personalisation or {},
|
||||
status=status,
|
||||
starts_at=starts_at,
|
||||
finishes_at=finishes_at,
|
||||
created_by_id=created_by.id if created_by else template.created_by_id,
|
||||
areas=areas,
|
||||
areas=areas or {},
|
||||
)
|
||||
db.session.add(broadcast_message)
|
||||
db.session.commit()
|
||||
|
||||
Reference in New Issue
Block a user