Require that modules register their callbacks using keyword arguments. (#11975)

To allow for easier backwards/forwards compatibility by making
it easier to add/remove callbacks.
This commit is contained in:
Patrick Cloke 2022-02-14 09:18:44 -05:00 committed by GitHub
parent 4ae956c8bb
commit 738e569ed2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

1
changelog.d/11975.bugfix Normal file
View File

@ -0,0 +1 @@
Require that modules register their callbacks using keyword arguments.

View File

@ -211,6 +211,7 @@ class ModuleApi:
def register_spam_checker_callbacks( def register_spam_checker_callbacks(
self, self,
*,
check_event_for_spam: Optional[CHECK_EVENT_FOR_SPAM_CALLBACK] = None, check_event_for_spam: Optional[CHECK_EVENT_FOR_SPAM_CALLBACK] = None,
user_may_join_room: Optional[USER_MAY_JOIN_ROOM_CALLBACK] = None, user_may_join_room: Optional[USER_MAY_JOIN_ROOM_CALLBACK] = None,
user_may_invite: Optional[USER_MAY_INVITE_CALLBACK] = None, user_may_invite: Optional[USER_MAY_INVITE_CALLBACK] = None,
@ -245,6 +246,7 @@ class ModuleApi:
def register_account_validity_callbacks( def register_account_validity_callbacks(
self, self,
*,
is_user_expired: Optional[IS_USER_EXPIRED_CALLBACK] = None, is_user_expired: Optional[IS_USER_EXPIRED_CALLBACK] = None,
on_user_registration: Optional[ON_USER_REGISTRATION_CALLBACK] = None, on_user_registration: Optional[ON_USER_REGISTRATION_CALLBACK] = None,
on_legacy_send_mail: Optional[ON_LEGACY_SEND_MAIL_CALLBACK] = None, on_legacy_send_mail: Optional[ON_LEGACY_SEND_MAIL_CALLBACK] = None,
@ -265,6 +267,7 @@ class ModuleApi:
def register_third_party_rules_callbacks( def register_third_party_rules_callbacks(
self, self,
*,
check_event_allowed: Optional[CHECK_EVENT_ALLOWED_CALLBACK] = None, check_event_allowed: Optional[CHECK_EVENT_ALLOWED_CALLBACK] = None,
on_create_room: Optional[ON_CREATE_ROOM_CALLBACK] = None, on_create_room: Optional[ON_CREATE_ROOM_CALLBACK] = None,
check_threepid_can_be_invited: Optional[ check_threepid_can_be_invited: Optional[
@ -289,6 +292,7 @@ class ModuleApi:
def register_presence_router_callbacks( def register_presence_router_callbacks(
self, self,
*,
get_users_for_states: Optional[GET_USERS_FOR_STATES_CALLBACK] = None, get_users_for_states: Optional[GET_USERS_FOR_STATES_CALLBACK] = None,
get_interested_users: Optional[GET_INTERESTED_USERS_CALLBACK] = None, get_interested_users: Optional[GET_INTERESTED_USERS_CALLBACK] = None,
) -> None: ) -> None:
@ -303,6 +307,7 @@ class ModuleApi:
def register_password_auth_provider_callbacks( def register_password_auth_provider_callbacks(
self, self,
*,
check_3pid_auth: Optional[CHECK_3PID_AUTH_CALLBACK] = None, check_3pid_auth: Optional[CHECK_3PID_AUTH_CALLBACK] = None,
on_logged_out: Optional[ON_LOGGED_OUT_CALLBACK] = None, on_logged_out: Optional[ON_LOGGED_OUT_CALLBACK] = None,
auth_checkers: Optional[ auth_checkers: Optional[
@ -327,6 +332,7 @@ class ModuleApi:
def register_background_update_controller_callbacks( def register_background_update_controller_callbacks(
self, self,
*,
on_update: ON_UPDATE_CALLBACK, on_update: ON_UPDATE_CALLBACK,
default_batch_size: Optional[DEFAULT_BATCH_SIZE_CALLBACK] = None, default_batch_size: Optional[DEFAULT_BATCH_SIZE_CALLBACK] = None,
min_batch_size: Optional[MIN_BATCH_SIZE_CALLBACK] = None, min_batch_size: Optional[MIN_BATCH_SIZE_CALLBACK] = None,