From 910a681f4b83d1c7ec646b8a7b524d52d8f83da9 Mon Sep 17 00:00:00 2001 From: Tulir Asokan Date: Sun, 14 Aug 2022 12:49:45 +0300 Subject: [PATCH] Mark key parameters as positional-only in async getter lock methods --- mautrix_telegram/portal.py | 4 ++-- mautrix_telegram/puppet.py | 4 ++-- mautrix_telegram/user.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/mautrix_telegram/portal.py b/mautrix_telegram/portal.py index 5216a1e3..886b48e7 100644 --- a/mautrix_telegram/portal.py +++ b/mautrix_telegram/portal.py @@ -3229,7 +3229,7 @@ class Portal(DBPortal, BasePortal): @classmethod @async_getter_lock - async def get_by_mxid(cls, mxid: RoomID) -> Portal | None: + async def get_by_mxid(cls, mxid: RoomID, /) -> Portal | None: try: return cls.by_mxid[mxid] except KeyError: @@ -3270,7 +3270,7 @@ class Portal(DBPortal, BasePortal): @classmethod @async_getter_lock async def get_by_tgid( - cls, tgid: TelegramID, *, tg_receiver: TelegramID | None = None, peer_type: str = None + cls, tgid: TelegramID, /, *, tg_receiver: TelegramID | None = None, peer_type: str = None ) -> Portal | None: if peer_type == "user" and tg_receiver is None: raise ValueError('tg_receiver is required when peer_type is "user"') diff --git a/mautrix_telegram/puppet.py b/mautrix_telegram/puppet.py index f7fb63e1..37e39076 100644 --- a/mautrix_telegram/puppet.py +++ b/mautrix_telegram/puppet.py @@ -406,7 +406,7 @@ class Puppet(DBPuppet, BasePuppet): @classmethod @async_getter_lock async def get_by_tgid( - cls, tgid: TelegramID, *, create: bool = True, is_channel: bool = False + cls, tgid: TelegramID, /, *, create: bool = True, is_channel: bool = False ) -> Puppet | None: if tgid is None: return None @@ -459,7 +459,7 @@ class Puppet(DBPuppet, BasePuppet): @classmethod @async_getter_lock - async def get_by_custom_mxid(cls, mxid: UserID) -> Puppet | None: + async def get_by_custom_mxid(cls, mxid: UserID, /) -> Puppet | None: try: return cls.by_custom_mxid[mxid] except KeyError: diff --git a/mautrix_telegram/user.py b/mautrix_telegram/user.py index a8c38217..4641523d 100644 --- a/mautrix_telegram/user.py +++ b/mautrix_telegram/user.py @@ -711,7 +711,7 @@ class User(DBUser, AbstractUser, BaseUser): @classmethod @async_getter_lock async def get_by_mxid( - cls, mxid: UserID, *, check_db: bool = True, create: bool = True + cls, mxid: UserID, /, *, check_db: bool = True, create: bool = True ) -> User | None: if not mxid or pu.Puppet.get_id_from_mxid(mxid) or mxid == cls.az.bot_mxid: return None @@ -739,7 +739,7 @@ class User(DBUser, AbstractUser, BaseUser): @classmethod @async_getter_lock - async def get_by_tgid(cls, tgid: TelegramID) -> User | None: + async def get_by_tgid(cls, tgid: TelegramID, /) -> User | None: try: return cls.by_tgid[tgid] except KeyError: