fix: LiteUserの属性instanceでkeyErrorになる可能性がある

pull/20/head
yupix 2 years ago
parent 32d3f68e8b
commit 11f52d739d
No known key found for this signature in database
GPG Key ID: 2FF705F5C56D9C06

@ -52,5 +52,9 @@ class LiteUser:
return self.__user['emojis']
@property
def instance(self) -> LiteInstance:
return LiteInstance(self.__user['instance'])
def instance(self) -> LiteInstance | None:
return (
LiteInstance(self.__user['instance'])
if 'instance' in self.__user
else None
)

@ -9,6 +9,7 @@ if TYPE_CHECKING:
from mipac.types.note import INote
from mipac.types.page import IPage
__all__ = (
'IUserRequired',
'IChannel',
'ILiteUser',
'IUserDetailed',
@ -16,15 +17,18 @@ __all__ = (
)
class ILiteUser(TypedDict):
class IUserRequired(TypedDict):
id: str
username: str
host: str | None
name: str
online_status: Literal['online', 'active', 'offline', 'unknown']
avatar_url: str
avatar_blurhash: str
emojis: list[ICustomEmojiLite]
class ILiteUser(IUserRequired, total=False):
host: str
instance: IInstanceLite

Loading…
Cancel
Save