diff --git a/inbox/api/kellogs.py b/inbox/api/kellogs.py index 0a94c4f10..6e92aa340 100644 --- a/inbox/api/kellogs.py +++ b/inbox/api/kellogs.py @@ -64,12 +64,7 @@ def format_messagecategories(messagecategories): def format_phone_numbers(phone_numbers): formatted_phone_numbers = [] for number in phone_numbers: - formatted_phone_numbers.append( - { - "type": number.type, - "number": number.number, - } - ) + formatted_phone_numbers.append({"type": number.type, "number": number.number}) return formatted_phone_numbers diff --git a/inbox/api/ns_api.py b/inbox/api/ns_api.py index 357b37576..44c6b59c5 100644 --- a/inbox/api/ns_api.py +++ b/inbox/api/ns_api.py @@ -333,10 +333,7 @@ def status(): else: account.throttled = False return g.encoder.jsonify( - { - "sync_status": account.sync_status, - "throttled": account.throttled, - } + {"sync_status": account.sync_status, "throttled": account.throttled} ) @@ -2026,10 +2023,7 @@ def sync_deltas(): expand=expand, ) - response = { - "cursor_start": cursor, - "deltas": deltas, - } + response = {"cursor_start": cursor, "deltas": deltas} if deltas: end_transaction = g.db_session.query(Transaction).get(end_pointer) response["cursor_end"] = deltas[-1]["cursor"] diff --git a/inbox/api/update.py b/inbox/api/update.py index 3a65fac3c..0aa0e72ef 100644 --- a/inbox/api/update.py +++ b/inbox/api/update.py @@ -37,10 +37,7 @@ def update_message(message, request_data, db_session, optimistic): def update_thread(thread, request_data, db_session, optimistic): accept_labels = thread.namespace.account.provider == "gmail" - ( - unread, - starred, - ) = parse_flags(request_data) + (unread, starred) = parse_flags(request_data) if accept_labels: labels = parse_labels(request_data, db_session, thread.namespace_id) else: diff --git a/inbox/auth/generic.py b/inbox/auth/generic.py index 434efd3e2..a366c5c3c 100644 --- a/inbox/auth/generic.py +++ b/inbox/auth/generic.py @@ -71,11 +71,7 @@ def authenticate_imap_connection(self, account, conn): conn.login(account.imap_username, account.imap_password) except IMAPClient.Error as exc: if auth_is_invalid(exc): - log.error( - "IMAP login failed", - account_id=account.id, - error=exc, - ) + log.error("IMAP login failed", account_id=account.id, error=exc) raise ValidationError(exc) elif auth_requires_app_password(exc): raise AppPasswordError(exc) diff --git a/inbox/auth/oauth.py b/inbox/auth/oauth.py index f05a10536..7efdd9389 100644 --- a/inbox/auth/oauth.py +++ b/inbox/auth/oauth.py @@ -219,9 +219,7 @@ def authenticate_imap_connection(self, account: OAuthAccount, conn: IMAPClient): raise exc from original_exc log.warning( - "Error during IMAP XOAUTH2 login", - account_id=account.id, - error=exc, + "Error during IMAP XOAUTH2 login", account_id=account.id, error=exc ) if not isinstance(exc, ImapSupportDisabledError): raise # Unknown IMAPClient error, reraise diff --git a/inbox/auth/utils.py b/inbox/auth/utils.py index bf6197795..c70585db0 100644 --- a/inbox/auth/utils.py +++ b/inbox/auth/utils.py @@ -89,10 +89,7 @@ def create_imap_connection(host, port, use_timeout=True): try: conn.starttls(context) except Exception: - log.warning( - "STARTTLS supported but failed.", - exc_info=True, - ) + log.warning("STARTTLS supported but failed.", exc_info=True) raise else: raise SSLNotSupportedError("Required IMAP STARTTLS not supported.") diff --git a/inbox/config.py b/inbox/config.py index a9ef838bb..b2c7363af 100644 --- a/inbox/config.py +++ b/inbox/config.py @@ -79,10 +79,7 @@ def _update_config_from_env(config, env): srcdir = os.path.join(os.path.dirname(os.path.realpath(__file__)), "..") if env in ["prod", "staging"]: - base_cfg_path = [ - "/etc/inboxapp/secrets.yml", - "/etc/inboxapp/config.json", - ] + base_cfg_path = ["/etc/inboxapp/secrets.yml", "/etc/inboxapp/config.json"] else: v = {"env": env, "srcdir": srcdir} base_cfg_path = [ diff --git a/inbox/contacts/carddav.py b/inbox/contacts/carddav.py index b986bd95c..bcee51f83 100644 --- a/inbox/contacts/carddav.py +++ b/inbox/contacts/carddav.py @@ -118,11 +118,7 @@ def get_cards(self, url): """ - response = self.session.request( - "REPORT", - url, - data=payload, - ) + response = self.session.request("REPORT", url, data=payload) response.raise_for_status() return response.content diff --git a/inbox/contacts/vcard.py b/inbox/contacts/vcard.py index 200593f43..fc8d37432 100644 --- a/inbox/contacts/vcard.py +++ b/inbox/contacts/vcard.py @@ -176,12 +176,7 @@ def vcard_from_vobject(vcard): if isinstance(property_value, list): property_value = (",").join(property_value) - vdict[property_name].append( - ( - property_value, - line.params, - ) - ) + vdict[property_name].append((property_value, line.params)) return vdict diff --git a/inbox/crispin.py b/inbox/crispin.py index 5d8a615c7..d2572de2a 100644 --- a/inbox/crispin.py +++ b/inbox/crispin.py @@ -1212,9 +1212,7 @@ def condstore_changed_flags( self, modseq: int ) -> Dict[int, Union[GmailFlags, Flags]]: data: Dict[int, Dict[bytes, Any]] = self.conn.fetch( - "1:*", - ["FLAGS", "X-GM-LABELS"], - modifiers=[f"CHANGEDSINCE {modseq}"], + "1:*", ["FLAGS", "X-GM-LABELS"], modifiers=[f"CHANGEDSINCE {modseq}"] ) results: Dict[int, Union[GmailFlags, Flags]] = {} for uid, ret in data.items(): diff --git a/inbox/error_handling.py b/inbox/error_handling.py index 0a07d23ce..b9e3f5f8a 100644 --- a/inbox/error_handling.py +++ b/inbox/error_handling.py @@ -33,10 +33,7 @@ def emit(self, record): ): return - record.payload_data = { - "fingerprint": event, - "title": event, - } + record.payload_data = {"fingerprint": event, "title": event} return super().emit(record) @@ -110,9 +107,7 @@ def maybe_enable_rollbar(): ) rollbar.init( - ROLLBAR_API_KEY, - application_environment, - allow_logging_basic_config=False, + ROLLBAR_API_KEY, application_environment, allow_logging_basic_config=False ) rollbar_handler = SyncEngineRollbarHandler() diff --git a/inbox/events/google.py b/inbox/events/google.py index bd08b94c2..0c3cb9cf9 100644 --- a/inbox/events/google.py +++ b/inbox/events/google.py @@ -539,7 +539,7 @@ def sanitize_conference_data( if entry_point.get("uri") ][:MAX_LIST_LENGTH], conference_solution=ConferenceSolution( - name=raw_conference_solution.get("name", "")[:MAX_STRING_LENGTH], + name=raw_conference_solution.get("name", "")[:MAX_STRING_LENGTH] ), ) diff --git a/inbox/events/microsoft/graph_client.py b/inbox/events/microsoft/graph_client.py index b25fdc954..ad3add2ca 100644 --- a/inbox/events/microsoft/graph_client.py +++ b/inbox/events/microsoft/graph_client.py @@ -195,7 +195,7 @@ def iter_events( # The default amount of events per page is 10, # as we want to do the least # amount of requests possible we raise it to 500. - "top": "500", + "top": "500" } if modified_after: @@ -269,10 +269,7 @@ def iter_event_instances( if fields: params["$select"] = ",".join(fields) - yield from self._iter( - f"/me/events/{event_id}/instances", - params=params, - ) + yield from self._iter(f"/me/events/{event_id}/instances", params=params) def iter_subscriptions(self) -> Iterable[Dict[str, Any]]: """ @@ -403,9 +400,7 @@ def renew_subscription( ) assert expiration.tzinfo == pytz.UTC - json = { - "expirationDateTime": format_datetime(expiration), - } + json = {"expirationDateTime": format_datetime(expiration)} return self.request("PATCH", f"/subscriptions/{subscription_id}", json=json) diff --git a/inbox/events/microsoft/graph_types.py b/inbox/events/microsoft/graph_types.py index 348095382..44bda01f6 100644 --- a/inbox/events/microsoft/graph_types.py +++ b/inbox/events/microsoft/graph_types.py @@ -33,12 +33,7 @@ class MsGraphDateTimeTimeZone(TypedDict): "relativeYearly", ] -ICalFreq = Literal[ - "DAILY", - "WEEKLY", - "MONTHLY", - "YEARLY", -] +ICalFreq = Literal["DAILY", "WEEKLY", "MONTHLY", "YEARLY"] class MsGraphRecurrencePattern(TypedDict): diff --git a/inbox/events/microsoft/parse.py b/inbox/events/microsoft/parse.py index 2adfd5bde..a06dfde89 100644 --- a/inbox/events/microsoft/parse.py +++ b/inbox/events/microsoft/parse.py @@ -299,9 +299,7 @@ def convert_msgraph_patterned_recurrence_to_ical_rrule( ] interval = pattern["interval"] * multiplier - rrule: Dict[str, str] = { - "FREQ": freq, - } + rrule: Dict[str, str] = {"FREQ": freq} if interval != 1: rrule["INTERVAL"] = str(interval) @@ -620,10 +618,7 @@ def validate_event(event: MsGraphEvent) -> bool: def parse_event( - event: MsGraphEvent, - *, - read_only: bool, - master_event_uid: Optional[str] = None, + event: MsGraphEvent, *, read_only: bool, master_event_uid: Optional[str] = None ) -> Event: """ Parse event coming from Microsoft Graph API as ORM object. diff --git a/inbox/ignition.py b/inbox/ignition.py index 54034c0f5..531553f32 100644 --- a/inbox/ignition.py +++ b/inbox/ignition.py @@ -281,7 +281,5 @@ def reset_invalid_autoincrements(engine, schema, key, dry_run=True): # these are _required_. nylas shouldn't start if these aren't present. redis_txn = redis.Redis( - config["TXN_REDIS_HOSTNAME"], - int(config["REDIS_PORT"]), - db=config["TXN_REDIS_DB"], + config["TXN_REDIS_HOSTNAME"], int(config["REDIS_PORT"]), db=config["TXN_REDIS_DB"] ) diff --git a/inbox/mailsync/frontend.py b/inbox/mailsync/frontend.py index 28b5dadb4..5b2aea14a 100644 --- a/inbox/mailsync/frontend.py +++ b/inbox/mailsync/frontend.py @@ -102,12 +102,7 @@ def build_metadata(): _, build_id = f.readline().rstrip("\n").split() build_id = build_id[1:-1] # Remove first and last single quotes. _, git_commit = f.readline().rstrip("\n").split() - return jsonify( - { - "build_id": build_id, - "git_commit": git_commit, - } - ) + return jsonify({"build_id": build_id, "git_commit": git_commit}) class _QuietHandler(WSGIRequestHandler): diff --git a/inbox/mailsync/service.py b/inbox/mailsync/service.py index 1a0c38b37..a3b6b9409 100644 --- a/inbox/mailsync/service.py +++ b/inbox/mailsync/service.py @@ -112,10 +112,7 @@ def __init__( SYNC_EVENT_QUEUE_NAME.format(self.process_identifier) ) self.queue_group = EventQueueGroup( - [ - shared_sync_event_queue_for_zone(self.zone), - self.private_queue, - ] + [shared_sync_event_queue_for_zone(self.zone), self.private_queue] ) self.stealing_enabled = config.get("SYNC_STEAL_ACCOUNTS", True) diff --git a/inbox/models/backends/imap.py b/inbox/models/backends/imap.py index 1523db942..b584cad87 100644 --- a/inbox/models/backends/imap.py +++ b/inbox/models/backends/imap.py @@ -215,13 +215,7 @@ def categories(self) -> Set[Category]: categories.add(self.folder.category) return categories - __table_args__ = ( - UniqueConstraint( - "folder_id", - "msg_uid", - "account_id", - ), - ) + __table_args__ = (UniqueConstraint("folder_id", "msg_uid", "account_id"),) # make pulling up all messages in a given folder fast diff --git a/inbox/sendmail/smtp/postel.py b/inbox/sendmail/smtp/postel.py index c0607fa96..4434a81ac 100644 --- a/inbox/sendmail/smtp/postel.py +++ b/inbox/sendmail/smtp/postel.py @@ -186,10 +186,7 @@ def _upgrade_connection(self): try: self.connection.starttls() except ssl.SSLError as e: - log.warning( - "STARTTLS supported but failed.", - exc_info=True, - ) + log.warning("STARTTLS supported but failed.", exc_info=True) msg = _transform_ssl_error(e.strerror) raise SendMailException(msg, 503) else: diff --git a/inbox/sendmail/smtp/util.py b/inbox/sendmail/smtp/util.py index a7f0a23c5..d89232560 100644 --- a/inbox/sendmail/smtp/util.py +++ b/inbox/sendmail/smtp/util.py @@ -24,26 +24,17 @@ "4.3.5": (429, "Mail server temporarily rejected message."), "4.7.1": (429, "Mail server temporarily rejected message."), }, - 452: { - "4.5.3": (402, "Your message has too many recipients"), - }, + 452: {"4.5.3": (402, "Your message has too many recipients")}, 454: { "4.7.0": ( 429, "Cannot authenticate due to temporary system problem. Try again later.", ) }, - 522: { - "5.7.1": (402, "Recipient address rejected."), - }, - 530: { - "5.7.0": (402, "Recipient address rejected"), - }, + 522: {"5.7.1": (402, "Recipient address rejected.")}, + 530: {"5.7.0": (402, "Recipient address rejected")}, 535: { - "5.7.1": ( - 429, - "Please log in to Gmail with your web browser and try again.", - ), + "5.7.1": (429, "Please log in to Gmail with your web browser and try again.") }, 550: { "5.1.1": ( diff --git a/inbox/transactions/search.py b/inbox/transactions/search.py index 79af8407f..093cdfab8 100644 --- a/inbox/transactions/search.py +++ b/inbox/transactions/search.py @@ -40,25 +40,19 @@ def __init__(self, poll_interval=30, chunk_size=DOC_UPLOAD_CHUNK_SIZE): Greenlet.__init__(self) def _report_batch_upload(self): - metric_names = [ - "contacts_search_index.transactions.batch_upload", - ] + metric_names = ["contacts_search_index.transactions.batch_upload"] for metric in metric_names: statsd_client.incr(metric) def _report_transactions_latency(self, latency): - metric_names = [ - "contacts_search_index.transactions.latency", - ] + metric_names = ["contacts_search_index.transactions.latency"] for metric in metric_names: statsd_client.timing(metric, latency) def _publish_heartbeat(self): - metric_names = [ - "contacts_search_index.heartbeat", - ] + metric_names = ["contacts_search_index.heartbeat"] for metric in metric_names: statsd_client.incr(metric) diff --git a/inbox/util/blockstore.py b/inbox/util/blockstore.py index a11a1e6b1..dd4011bcd 100644 --- a/inbox/util/blockstore.py +++ b/inbox/util/blockstore.py @@ -19,13 +19,7 @@ def _data_file_directory(h): return os.path.join( - config.get_required("MSG_PARTS_DIRECTORY"), - h[0], - h[1], - h[2], - h[3], - h[4], - h[5], + config.get_required("MSG_PARTS_DIRECTORY"), h[0], h[1], h[2], h[3], h[4], h[5] ) diff --git a/inbox/util/testutils.py b/inbox/util/testutils.py index 5d38907d8..f59a646cf 100644 --- a/inbox/util/testutils.py +++ b/inbox/util/testutils.py @@ -82,10 +82,7 @@ class MockDNSResolver: def __init__(self): self._registry: Dict[ Literal["mx", "ns"], Dict[str, Union[Dict[str, str], List[str]]] - ] = { - "mx": {}, - "ns": {}, - } + ] = {"mx": {}, "ns": {}} def _load_records(self, filename): self._registry = json.loads(get_data(filename)) diff --git a/inbox/webhooks/microsoft_notifications.py b/inbox/webhooks/microsoft_notifications.py index fc9f18eab..c517ba815 100644 --- a/inbox/webhooks/microsoft_notifications.py +++ b/inbox/webhooks/microsoft_notifications.py @@ -142,8 +142,7 @@ def event_update(calendar_public_id): def handle_event_deletions( - calendar: Calendar, - change_notifications: List[MsGraphChangeNotification], + calendar: Calendar, change_notifications: List[MsGraphChangeNotification] ) -> None: deleted_event_uids = [ change_notification["resourceData"]["id"] diff --git a/migrations/versions/018_message_contact_association.py b/migrations/versions/018_message_contact_association.py index a0549974e..af5dd650b 100644 --- a/migrations/versions/018_message_contact_association.py +++ b/migrations/versions/018_message_contact_association.py @@ -26,14 +26,8 @@ def upgrade(): sa.Enum("from_addr", "to_addr", "cc_addr", "bcc_addr"), nullable=True, ), - sa.ForeignKeyConstraint( - ["contact_id"], - ["contact.id"], - ), - sa.ForeignKeyConstraint( - ["message_id"], - ["message.id"], - ), + sa.ForeignKeyConstraint(["contact_id"], ["contact.id"]), + sa.ForeignKeyConstraint(["message_id"], ["message.id"]), sa.PrimaryKeyConstraint("id", "contact_id", "message_id"), ) diff --git a/migrations/versions/059_add_action_log.py b/migrations/versions/059_add_action_log.py index 8b95add96..ad58a7cc7 100644 --- a/migrations/versions/059_add_action_log.py +++ b/migrations/versions/059_add_action_log.py @@ -25,10 +25,7 @@ def upgrade(): sa.Column("action", sa.Text(length=40), nullable=False), sa.Column("record_id", sa.Integer(), nullable=False), sa.Column("table_name", sa.Text(length=40), nullable=False), - sa.ForeignKeyConstraint( - ["namespace_id"], - ["namespace.id"], - ), + sa.ForeignKeyConstraint(["namespace_id"], ["namespace.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( diff --git a/migrations/versions/067_add_executed_status_to_action_log.py b/migrations/versions/067_add_executed_status_to_action_log.py index fcf69588e..eba91b48f 100644 --- a/migrations/versions/067_add_executed_status_to_action_log.py +++ b/migrations/versions/067_add_executed_status_to_action_log.py @@ -33,10 +33,7 @@ def upgrade(): nullable=False, server_default=sa.sql.expression.false(), ), - sa.ForeignKeyConstraint( - ["namespace_id"], - ["namespace.id"], - ), + sa.ForeignKeyConstraint(["namespace_id"], ["namespace.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( diff --git a/migrations/versions/091_remove_webhooks.py b/migrations/versions/091_remove_webhooks.py index 48c95a214..e9c4496ae 100644 --- a/migrations/versions/091_remove_webhooks.py +++ b/migrations/versions/091_remove_webhooks.py @@ -48,10 +48,7 @@ def downgrade(): sa.Column("filename", mysql.VARCHAR(length=255), nullable=True), sa.Column("tag", mysql.VARCHAR(length=255), nullable=True), sa.ForeignKeyConstraint( - ["namespace_id"], - ["namespace.id"], - name="lens_ibfk_1", - ondelete="CASCADE", + ["namespace_id"], ["namespace.id"], name="lens_ibfk_1", ondelete="CASCADE" ), sa.PrimaryKeyConstraint("id"), mysql_default_charset="utf8mb4", diff --git a/migrations/versions/121_add_searchindexcursor.py b/migrations/versions/121_add_searchindexcursor.py index e51299b04..f1a8cd6dc 100644 --- a/migrations/versions/121_add_searchindexcursor.py +++ b/migrations/versions/121_add_searchindexcursor.py @@ -22,10 +22,7 @@ def upgrade(): sa.Column("deleted_at", sa.DateTime(), nullable=True), sa.Column("id", sa.Integer(), nullable=False), sa.Column("transaction_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["transaction_id"], - ["transaction.id"], - ), + sa.ForeignKeyConstraint(["transaction_id"], ["transaction.id"]), sa.PrimaryKeyConstraint("id"), ) diff --git a/migrations/versions/150_add_polymorphic_events.py b/migrations/versions/150_add_polymorphic_events.py index 0b64ad5b4..5676c4a7d 100644 --- a/migrations/versions/150_add_polymorphic_events.py +++ b/migrations/versions/150_add_polymorphic_events.py @@ -33,10 +33,7 @@ def upgrade(): sa.Column("original_start_time", sa.DateTime(), nullable=True), sa.Column("cancelled", sa.Boolean(), default=False), sa.ForeignKeyConstraint(["id"], ["event.id"], ondelete="CASCADE"), - sa.ForeignKeyConstraint( - ["master_event_id"], - ["event.id"], - ), + sa.ForeignKeyConstraint(["master_event_id"], ["event.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_table( diff --git a/migrations/versions/186_new_tables_for_folders_overhaul.py b/migrations/versions/186_new_tables_for_folders_overhaul.py index f8e9c3392..e317b42f9 100644 --- a/migrations/versions/186_new_tables_for_folders_overhaul.py +++ b/migrations/versions/186_new_tables_for_folders_overhaul.py @@ -54,10 +54,7 @@ def upgrade(): sa.ForeignKeyConstraint( ["account_id"], ["account.id"], name="label_fk1", ondelete="CASCADE" ), - sa.ForeignKeyConstraint( - ["category_id"], - ["category.id"], - ), + sa.ForeignKeyConstraint(["category_id"], ["category.id"]), sa.PrimaryKeyConstraint("id"), sa.UniqueConstraint("account_id", "name"), ) diff --git a/migrations/versions/207_add_contact_search_index_service_cursor_.py b/migrations/versions/207_add_contact_search_index_service_cursor_.py index 4e82ca65f..19be8344a 100644 --- a/migrations/versions/207_add_contact_search_index_service_cursor_.py +++ b/migrations/versions/207_add_contact_search_index_service_cursor_.py @@ -23,10 +23,7 @@ def upgrade(): sa.Column("deleted_at", sa.DateTime(), nullable=True), sa.Column("id", sa.Integer(), nullable=False), sa.Column("transaction_id", sa.Integer(), nullable=True), - sa.ForeignKeyConstraint( - ["transaction_id"], - ["transaction.id"], - ), + sa.ForeignKeyConstraint(["transaction_id"], ["transaction.id"]), sa.PrimaryKeyConstraint("id"), ) op.create_index( diff --git a/migrations/versions/214_introduce_accounttransaction.py b/migrations/versions/214_introduce_accounttransaction.py index cab55720a..1268c0868 100644 --- a/migrations/versions/214_introduce_accounttransaction.py +++ b/migrations/versions/214_introduce_accounttransaction.py @@ -31,10 +31,7 @@ def upgrade(): sa.Column("object_public_id", sa.String(191), nullable=False), sa.Column("command", sa.Enum("insert", "update", "delete"), nullable=False), sa.PrimaryKeyConstraint("id"), - sa.ForeignKeyConstraint( - ["namespace_id"], - ["namespace.id"], - ), + sa.ForeignKeyConstraint(["namespace_id"], ["namespace.id"]), ) op.create_index( "ix_accounttransaction_created_at", diff --git a/migrations/versions/248_event_contact_association.py b/migrations/versions/248_event_contact_association.py index 954a532f7..6a17e2a1b 100644 --- a/migrations/versions/248_event_contact_association.py +++ b/migrations/versions/248_event_contact_association.py @@ -18,10 +18,7 @@ def upgrade(): op.create_table( "eventcontactassociation", sa.Column( - "created_at", - sa.DateTime(), - nullable=False, - server_default=sa.text("now()"), + "created_at", sa.DateTime(), nullable=False, server_default=sa.text("now()") ), sa.Column("id", sa.BigInteger(), nullable=False, autoincrement=True), sa.Column("contact_id", sa.BigInteger(), nullable=False), @@ -31,14 +28,8 @@ def upgrade(): sa.Enum("participant", "title", "description", "owner"), nullable=True, ), - sa.ForeignKeyConstraint( - ["contact_id"], - ["contact.id"], - ), - sa.ForeignKeyConstraint( - ["event_id"], - ["event.id"], - ), + sa.ForeignKeyConstraint(["contact_id"], ["contact.id"]), + sa.ForeignKeyConstraint(["event_id"], ["event.id"]), sa.PrimaryKeyConstraint("id", "contact_id", "event_id"), ) op.create_index( diff --git a/pyproject.toml b/pyproject.toml index 8cd5b05c1..c576a0904 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -10,3 +10,6 @@ include_trailing_comma = true force_grid_wrap = 0 combine_as_imports = true line_length = 88 + +[tool.black] +skip-magic-trailing-comma = true \ No newline at end of file diff --git a/tests/api/test_calendars.py b/tests/api/test_calendars.py index bc4e21b69..e817761fe 100644 --- a/tests/api/test_calendars.py +++ b/tests/api/test_calendars.py @@ -9,18 +9,10 @@ @pytest.mark.parametrize( - "uid,default", - [ - ("inboxapptest@gmail.com", True), - ("other", False), - ], + "uid,default", [("inboxapptest@gmail.com", True), ("other", False)] ) def test_get_google_calendar(db, default_namespace, api_client, uid, default): - cal = Calendar( - namespace_id=default_namespace.id, - uid=uid, - name="Holidays", - ) + cal = Calendar(namespace_id=default_namespace.id, uid=uid, name="Holidays") db.session.add(cal) db.session.commit() cal_id = cal.public_id @@ -37,10 +29,7 @@ def test_get_google_calendar(db, default_namespace, api_client, uid, default): def test_get_outlook_calendar(db, outlook_namespace, make_api_client): api_client = make_api_client(db, outlook_namespace) cal = Calendar( - namespace_id=outlook_namespace.id, - uid="uid", - name="Holidays", - default=False, + namespace_id=outlook_namespace.id, uid="uid", name="Holidays", default=False ) db.session.add(cal) db.session.commit() diff --git a/tests/api/test_drafts.py b/tests/api/test_drafts.py index 10430cf50..0d48e4f13 100644 --- a/tests/api/test_drafts.py +++ b/tests/api/test_drafts.py @@ -181,11 +181,7 @@ def test_drafts_filter(api_client, example_draft): @pytest.mark.usefixtures("blockstore_backend") @pytest.mark.parametrize("blockstore_backend", ["disk", "s3"], indirect=True) -def test_create_draft_with_attachments( - api_client, - attachments, - example_draft, -): +def test_create_draft_with_attachments(api_client, attachments, example_draft): attachment_ids = [] upload_path = "/files" for filename, path in attachments: diff --git a/tests/api/test_event_participants.py b/tests/api/test_event_participants.py index 5c833993c..8340713db 100644 --- a/tests/api/test_event_participants.py +++ b/tests/api/test_event_participants.py @@ -60,12 +60,8 @@ def test_api_create_multiple(db, api_client, calendar): "when": {"time": 1407542195}, "calendar_id": calendar.public_id, "participants": [ - { - "email": "alyssa@example.com", - }, - { - "email": "ben.bitdiddle@example.com", - }, + {"email": "alyssa@example.com"}, + {"email": "ben.bitdiddle@example.com"}, ], } @@ -162,11 +158,7 @@ def test_api_create_no_email(db, api_client, calendar): "title": "Friday Office Party", "when": {"time": 1407542195}, "calendar_id": calendar.public_id, - "participants": [ - { - "name": "alyssa p. hacker", - } - ], + "participants": [{"name": "alyssa p. hacker"}], } e_resp = api_client.post_data("/events", e_data) diff --git a/tests/api/test_event_when.py b/tests/api/test_event_when.py index 5cb9b453d..5fa79c24f 100644 --- a/tests/api/test_event_when.py +++ b/tests/api/test_event_when.py @@ -129,10 +129,7 @@ def test_api_invalid_event_when_bad_params(db, api_client, calendar, default_nam def test_api_invalid_event_when_timespan_bad_params( db, api_client, calendar, default_namespace ): - e_data = { - "title": "Friday Office Party", - "when": {"object": "time", "start": 0}, - } + e_data = {"title": "Friday Office Party", "when": {"object": "time", "start": 0}} with pytest.raises(CreateError): _verify_create(default_namespace.public_id, api_client, e_data) diff --git a/tests/api/test_files.py b/tests/api/test_files.py index 4d7c65dfd..724342f8f 100644 --- a/tests/api/test_files.py +++ b/tests/api/test_files.py @@ -148,10 +148,7 @@ def test_download(api_client, uploaded_file_ids, filename): data = api_client.get_raw("/files/{}/download".format(in_file["id"])).data path = os.path.join( - os.path.dirname(os.path.abspath(__file__)), - "..", - "data", - original_filename, + os.path.dirname(os.path.abspath(__file__)), "..", "data", original_filename ) with open(path, "rb") as fp: local_data = fp.read() diff --git a/tests/api/test_messages.py b/tests/api/test_messages.py index 8ab063022..be08c5977 100644 --- a/tests/api/test_messages.py +++ b/tests/api/test_messages.py @@ -196,8 +196,7 @@ def _check_json_thread(resp_dict): # /threads/ resp = api_client.get_raw( - f"/threads/{stub_message.thread.public_id}?view=expanded", - headers=headers, + f"/threads/{stub_message.thread.public_id}?view=expanded", headers=headers ) assert resp.status_code == 200 resp_dict = json.loads(resp.data) diff --git a/tests/api/test_searching.py b/tests/api/test_searching.py index 62ad9bebc..a7275f26d 100644 --- a/tests/api/test_searching.py +++ b/tests/api/test_searching.py @@ -487,14 +487,7 @@ def test_streaming_search_results( class MultiFolderMockImapConnection(MockImapConnection): def __init__(self): - self._responses = list( - reversed( - [ - [2000, 2001, 2002], - [5000, 5001], - ] - ) - ) + self._responses = list(reversed([[2000, 2001, 2002], [5000, 5001]])) def search(self, criteria, charset=None): self.search_args = (criteria, charset) diff --git a/tests/api/test_sending.py b/tests/api/test_sending.py index 19f6c7a4d..5cbef66eb 100644 --- a/tests/api/test_sending.py +++ b/tests/api/test_sending.py @@ -36,8 +36,7 @@ def patch_token_manager(monkeypatch): @pytest.fixture def disallow_auth(monkeypatch): monkeypatch.setattr( - "inbox.sendmail.smtp.postel.token_manager", - MockTokenManager(allow_auth=False), + "inbox.sendmail.smtp.postel.token_manager", MockTokenManager(allow_auth=False) ) @@ -845,11 +844,7 @@ def fake_conn_pool(acct_id): def test_multisend_session( - api_client, - multisend, - multisend2, - patch_smtp, - patch_crispin_del_sent, + api_client, multisend, multisend2, patch_smtp, patch_crispin_del_sent ): r = api_client.post_data("/send-multiple/" + multisend["id"], multisend["send_req"]) assert r.status_code == 200 diff --git a/tests/events/microsoft/test_events_provider.py b/tests/events/microsoft/test_events_provider.py index 76939976f..277f5a538 100644 --- a/tests/events/microsoft/test_events_provider.py +++ b/tests/events/microsoft/test_events_provider.py @@ -47,7 +47,7 @@ def calendars_response(): "canEdit": True, "isDefaultCalendar": False, }, - ], + ] }, ) @@ -131,7 +131,7 @@ def events_responses(): "uniqueIdType": "unknown", "address": {}, "coordinates": {}, - }, + } ], "recurrence": { "pattern": { @@ -220,9 +220,7 @@ def subscribe_responses(): ], ) - responses.delete( - BASE_URL + "/subscriptions/f798ca9d-d630-4306-b065-af52199f5613", - ) + responses.delete(BASE_URL + "/subscriptions/f798ca9d-d630-4306-b065-af52199f5613") @pytest.fixture @@ -371,7 +369,7 @@ def exception_override_response(): "uniqueIdType": "unknown", "address": {}, "coordinates": {}, - }, + } ], "recurrence": None, "attendees": [ diff --git a/tests/events/microsoft/test_graph_client.py b/tests/events/microsoft/test_graph_client.py index 03dc38cb3..3e9d7e7e4 100644 --- a/tests/events/microsoft/test_graph_client.py +++ b/tests/events/microsoft/test_graph_client.py @@ -40,7 +40,7 @@ def test_format_datetime(): "id": "AAMkADdiYzg5OGRlLTY1MjktNDc2Ni05YmVkLWMxMzFlNTQ0MzU3YQBGAAAAAACi9RQWB-SNTZBuALM6KIOsBwBtf4g8yY_zTZgZh6x0X-50AAAAAAEGAABtf4g8yY_zTZgZh6x0X-50AAIM0_ZOAAA=", "name": "Test", }, - ], + ] } @@ -115,10 +115,7 @@ def test_request_exception(client): @responses.activate def test_iter_calendars(client): - responses.get( - BASE_URL + "/me/calendars", - json=calendars_json, - ) + responses.get(BASE_URL + "/me/calendars", json=calendars_json) calendars = client.iter_calendars() assert {calendar["name"] for calendar in calendars} == { @@ -168,10 +165,7 @@ def test_get_calendar(client): @responses.activate def test_iter_events(client): - responses.get( - BASE_URL + "/me/calendars/fake_calendar_id/events", - json=events_json, - ) + responses.get(BASE_URL + "/me/calendars/fake_calendar_id/events", json=events_json) events = client.iter_events("fake_calendar_id") assert {event["subject"] for event in events} == { @@ -214,10 +208,7 @@ def request_callback(request): content_type="application/json", ) - events = client.iter_events( - "fake_calendar_id", - modified_after=modified_after, - ) + events = client.iter_events("fake_calendar_id", modified_after=modified_after) assert {event["subject"] for event in events} == subjects @@ -260,8 +251,7 @@ def test_get_event(client): @responses.activate(registry=OrderedRegistry) def test_iter_event_instances(client): responses.get( - BASE_URL + "/me/events/fake_event_id/instances", - json=event_instances_first_page, + BASE_URL + "/me/events/fake_event_id/instances", json=event_instances_first_page ) responses.get( @@ -293,11 +283,7 @@ def test_subscribe_connection_closed_retries(client): }, status=400, ) - responses.post( - BASE_URL + "/subscriptions", - json={}, - status=200, - ) + responses.post(BASE_URL + "/subscriptions", json={}, status=200) with unittest.mock.patch("time.sleep"): client.subscribe( @@ -396,10 +382,7 @@ def request_callback(request): @responses.activate(registry=OrderedRegistry) def test_iter_subscriptions(client): - responses.get( - BASE_URL + "/subscriptions", - json=subscriptions_json, - ) + responses.get(BASE_URL + "/subscriptions", json=subscriptions_json) subscriptions = client.iter_subscriptions() @@ -411,9 +394,6 @@ def test_iter_subscriptions(client): @responses.activate def test_unsubscribe(client): - responses.delete( - BASE_URL + "/subscriptions/fake_subscription_id", - body="", - ) + responses.delete(BASE_URL + "/subscriptions/fake_subscription_id", body="") assert client.unsubscribe("fake_subscription_id") == {} diff --git a/tests/events/microsoft/test_parse.py b/tests/events/microsoft/test_parse.py index f63e0b85f..2afd6c6e9 100644 --- a/tests/events/microsoft/test_parse.py +++ b/tests/events/microsoft/test_parse.py @@ -71,10 +71,7 @@ def test_parse_msggraph_datetime_tz_as_utc(datetime_tz, dt): def test_dump_datetime_as_msgraph_datetime_tz(): assert dump_datetime_as_msgraph_datetime_tz( datetime.datetime(2022, 9, 22, 16, 31, 45, tzinfo=pytz.UTC) - ) == { - "dateTime": "2022-09-22T16:31:45.0000000", - "timeZone": "UTC", - } + ) == {"dateTime": "2022-09-22T16:31:45.0000000", "timeZone": "UTC"} @pytest.mark.parametrize( @@ -1015,16 +1012,7 @@ def test_calculate_exception_and_canceled_occurrences_with_exception(): }, "Test Valley Golf Club Micheldever Road Overton, Basingstoke, Hampshire, RG25 3DS, United Kingdom", ), - ( - { - "locations": [ - { - "displayName": "Kitchen", - } - ] - }, - "Kitchen", - ), + ({"locations": [{"displayName": "Kitchen"}]}, "Kitchen"), ( { "onlineMeeting": { @@ -1119,12 +1107,7 @@ def test_get_event_location(event, location): }, "emailAddress": {"name": "Test User"}, }, - { - "email": None, - "name": "Test User", - "status": "maybe", - "notes": None, - }, + {"email": None, "name": "Test User", "status": "maybe", "notes": None}, ), ], ) @@ -1211,7 +1194,7 @@ def test_get_event_description(event, description): "uniqueIdType": "unknown", "address": {}, "coordinates": {}, - }, + } ], "recurrence": { "pattern": { @@ -1241,10 +1224,7 @@ def test_get_event_description(event, description): } ], "organizer": { - "emailAddress": { - "name": "Example", - "address": "example@example.com", - } + "emailAddress": {"name": "Example", "address": "example@example.com"} }, } @@ -1444,10 +1424,7 @@ def test_parse_event_with_organizer(organizer, owner): "defaultOnlineMeetingProvider": "teamsForBusiness", "isTallyingResponses": True, "isRemovable": True, - "owner": { - "name": "Example", - "address": "example@example.com", - }, + "owner": {"name": "Example", "address": "example@example.com"}, } diff --git a/tests/events/test_recurrence.py b/tests/events/test_recurrence.py index ba54321d7..dfadf1c80 100644 --- a/tests/events/test_recurrence.py +++ b/tests/events/test_recurrence.py @@ -27,14 +27,7 @@ def recurring_event( - db, - account, - calendar, - rrule, - start=None, - end=None, - all_day=False, - commit=True, + db, account, calendar, rrule, start=None, end=None, all_day=False, commit=True ): start = start or arrow.get(2014, 8, 7, 20, 30, 0) end = end or arrow.get(2014, 8, 7, 21, 30, 0) diff --git a/tests/general/test_message_parsing.py b/tests/general/test_message_parsing.py index d6d5dbdcc..422ce69d3 100644 --- a/tests/general/test_message_parsing.py +++ b/tests/general/test_message_parsing.py @@ -583,17 +583,7 @@ def test_long_message_body(db, default_account, raw_message_too_long): assert "over the parsing limit" in mock.warning.call_args[1]["error"].args[0] -@pytest.mark.parametrize( - "header", - [ - "From", - "Sender", - "Reply-To", - "To", - "Cc", - "Bcc", - ], -) +@pytest.mark.parametrize("header", ["From", "Sender", "Reply-To", "To", "Cc", "Bcc"]) def test_long_address_header(db, default_account, mime_message, header): with patch("inbox.models.message.log") as mock: mime_message.headers[header] = "b" * MAX_TEXT_BYTES + " " diff --git a/tests/imap/network/test_drafts_syncback.py b/tests/imap/network/test_drafts_syncback.py index b85f6eaf9..578d16313 100644 --- a/tests/imap/network/test_drafts_syncback.py +++ b/tests/imap/network/test_drafts_syncback.py @@ -19,10 +19,7 @@ def message(db, config): account = db.session.query(ImapAccount).get(ACCOUNT_ID) to = [ - { - "name": '"\u2605The red-haired mermaid\u2605"', - "email": account.email_address, - } + {"name": '"\u2605The red-haired mermaid\u2605"', "email": account.email_address} ] subject = "Draft test: " + str(uuid.uuid4().hex) body = "

Sea, birds, yoga and sand.

" diff --git a/tests/imap/test_actions.py b/tests/imap/test_actions.py index e31b68087..5adf458a9 100644 --- a/tests/imap/test_actions.py +++ b/tests/imap/test_actions.py @@ -143,10 +143,7 @@ def test_change_labels(db, default_account, message, folder, mock_imapclient): crispin_client, default_account.id, [message.id], - { - "removed_labels": ["\\Inbox"], - "added_labels": ["motörhead", "μετάνοια"], - }, + {"removed_labels": ["\\Inbox"], "added_labels": ["motörhead", "μετάνοια"]}, ) mock_imapclient.add_gmail_labels.assert_called_with( [22], [b"mot&APY-rhead", b"&A7wDtQPEA6wDvQO,A7kDsQ-"], silent=True diff --git a/tests/imap/test_folder_sync.py b/tests/imap/test_folder_sync.py index e7bcc161b..37c7929ec 100644 --- a/tests/imap/test_folder_sync.py +++ b/tests/imap/test_folder_sync.py @@ -272,14 +272,7 @@ def test_gmail_initial_sync(db, default_account, all_mail_folder, mock_imapclien uid_dict = uids.example() mock_imapclient.add_folder_data(all_mail_folder.name, uid_dict) mock_imapclient.list_folders = lambda: [ - ( - ( - b"\\All", - b"\\HasNoChildren", - ), - b"/", - "[Gmail]/All Mail", - ) + ((b"\\All", b"\\HasNoChildren"), b"/", "[Gmail]/All Mail") ] mock_imapclient.idle = lambda: None mock_imapclient.idle_check = raise_imap_error @@ -308,22 +301,8 @@ def test_gmail_message_deduplication( uid_values = uid_data.example() mock_imapclient.list_folders = lambda: [ - ( - ( - b"\\All", - b"\\HasNoChildren", - ), - b"/", - "[Gmail]/All Mail", - ), - ( - ( - b"\\Trash", - b"\\HasNoChildren", - ), - b"/", - "[Gmail]/Trash", - ), + ((b"\\All", b"\\HasNoChildren"), b"/", "[Gmail]/All Mail"), + ((b"\\Trash", b"\\HasNoChildren"), b"/", "[Gmail]/Trash"), ] mock_imapclient.idle = lambda: None mock_imapclient.add_folder_data(all_mail_folder.name, {uid: uid_values}) @@ -377,22 +356,8 @@ def test_imap_message_deduplication( uid_values = uid_data.example() mock_imapclient.list_folders = lambda: [ - ( - ( - b"\\All", - b"\\HasNoChildren", - ), - b"/", - "/Inbox", - ), - ( - ( - b"\\Trash", - b"\\HasNoChildren", - ), - b"/", - "/Trash", - ), + ((b"\\All", b"\\HasNoChildren"), b"/", "/Inbox"), + ((b"\\Trash", b"\\HasNoChildren"), b"/", "/Trash"), ] mock_imapclient.idle = lambda: None mock_imapclient.add_folder_data(inbox_folder.name, {uid: uid_values}) diff --git a/tests/imap/test_save_folder_names.py b/tests/imap/test_save_folder_names.py index 02cb9f33b..0de8a6c63 100644 --- a/tests/imap/test_save_folder_names.py +++ b/tests/imap/test_save_folder_names.py @@ -28,10 +28,7 @@ def test_imap_save_generic_folder_names(db, default_account): def test_handle_folder_deletions(db, default_account): monitor = ImapSyncMonitor(default_account) - folder_names_and_roles = { - ("INBOX", "inbox"), - ("Miscellania", None), - } + folder_names_and_roles = {("INBOX", "inbox"), ("Miscellania", None)} raw_folders = [RawFolder(*args) for args in folder_names_and_roles] monitor.save_folder_names(db.session, raw_folders) assert ( @@ -199,11 +196,7 @@ def test_handle_trailing_whitespace(db, default_account): def test_imap_remote_delete(db, default_account): monitor = ImapSyncMonitor(default_account) - folders = { - ("All", "inbox"), - ("Trash", "trash"), - ("Applications", ""), - } + folders = {("All", "inbox"), ("Trash", "trash"), ("Applications", "")} new_folders = {("All", "inbox"), ("Trash", "trash")} original_raw_folders = [RawFolder(*args) for args in folders] diff --git a/tests/scheduling/test_sync_start_logic.py b/tests/scheduling/test_sync_start_logic.py index 4121c32e0..ca6a8d48c 100644 --- a/tests/scheduling/test_sync_start_logic.py +++ b/tests/scheduling/test_sync_start_logic.py @@ -17,8 +17,7 @@ def patched_sync_service(db, host=host, process_number=0): s = SyncService( - process_identifier=f"{host}:{process_number}", - process_number=process_number, + process_identifier=f"{host}:{process_number}", process_number=process_number ) def start_sync(aid): diff --git a/tests/transactions/test_transaction_deletion.py b/tests/transactions/test_transaction_deletion.py index 8c7dbea6b..b7008219e 100644 --- a/tests/transactions/test_transaction_deletion.py +++ b/tests/transactions/test_transaction_deletion.py @@ -127,11 +127,7 @@ def test_transaction_deletion_purges_redis( ): def _get_redis_transactions(): return redis_txn.zrangebyscore( - TXN_REDIS_KEY, - "-inf", - "+inf", - withscores=True, - score_cast_func=int, + TXN_REDIS_KEY, "-inf", "+inf", withscores=True, score_cast_func=int ) assert db.session.query(Transaction).count() diff --git a/tests/util/base.py b/tests/util/base.py index 656b5cb18..8da8d2edd 100644 --- a/tests/util/base.py +++ b/tests/util/base.py @@ -119,8 +119,7 @@ def make_account(db, config, *, cls): ns = Namespace() account = cls( - sync_host=f"{platform.node()}:0", - email_address="inboxapptest@gmail.com", + sync_host=f"{platform.node()}:0", email_address="inboxapptest@gmail.com" ) account.namespace = ns account.client_id = config.get_required("GOOGLE_OAUTH_CLIENT_ID")