Skip to content

Commit

Permalink
chore: フォーマット
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Aug 29, 2022
1 parent e452d53 commit ccb8c3b
Show file tree
Hide file tree
Showing 14 changed files with 35 additions and 29 deletions.
2 changes: 1 addition & 1 deletion mipac/core/models/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from datetime import datetime
from typing import Any, Optional

from mipac.types.drive import IDriveFile, FolderPayload, PropertiesPayload
from mipac.types.drive import FolderPayload, IDriveFile, PropertiesPayload
from mipac.types.user import UserPayload

__all__ = ('RawProperties', 'RawFolder', 'RawFile')
Expand Down
1 change: 1 addition & 0 deletions mipac/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def __repr__(self):
MISSING: Any = _MissingSentinel()
R = TypeVar('R')


async def json_or_text(response: aiohttp.ClientResponse):
text = await response.text(encoding='utf-8')
try:
Expand Down
5 changes: 4 additions & 1 deletion mipac/manager/ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,8 @@ async def create(
'image_url': image_url,
}
return await self.__session.request(
Route('POST', '/api/admin/ad/create'), json=data, auth=True, lower=True
Route('POST', '/api/admin/ad/create'),
json=data,
auth=True,
lower=True,
)
5 changes: 2 additions & 3 deletions mipac/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
from .drive import File, Folder, Properties
from .emoji import Emoji
from .instance import Instance, InstanceMeta
from .note import Follow, Header, Note, NoteReaction, Poll, Renote
from .user import Followee, FollowRequest, User
from .note import Follow, Header, Note, NoteReaction, Poll
from .notification import Reaction
from .user import Followee, FollowRequest, User

__all__ = (
'Chat',
Expand All @@ -22,6 +22,5 @@
'Reaction',
'Follow',
'Header',
'Renote',
'NoteReaction',
)
23 changes: 13 additions & 10 deletions mipac/models/lite/user.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Literal

from mipac.models.lite.instance import InstanceLite
from mipac.types.emoji import ICustomEmojiLite
from mipac.types.user import IUserLite
Expand All @@ -7,27 +8,29 @@
class UserLite:
def __init__(self, user: IUserLite) -> None:
self.__user: IUserLite = user

@property
def id(self) -> str:
return self.__user['id']

@property
def username(self) -> str:
return self.__user['username']

@property
def host(self) -> str | None:
return self.__user['host']

@property
def name(self) -> str:
return self.__user['name']

@property
def online_status(self) -> Literal['online', 'active', 'offline', 'unknown']:
def online_status(
self,
) -> Literal['online', 'active', 'offline', 'unknown']:
return self.__user['online_status']

@property
def avatar_url(self) -> str:
return self.__user['avatar_url']
Expand All @@ -37,9 +40,9 @@ def avatar_blurhash(self) -> str:
return self.__user['avatar_blurhash']

@property
def emojis(self) -> list[ICustomEmojiLite]: # TODO: ちゃんとモデルにする
def emojis(self) -> list[ICustomEmojiLite]: # TODO: ちゃんとモデルにする
return self.__user['emojis']

@property
def instance(self) -> InstanceLite:
return InstanceLite(self.__user['instance'])
return InstanceLite(self.__user['instance'])
6 changes: 3 additions & 3 deletions mipac/models/note.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import annotations

from datetime import datetime
from typing import TYPE_CHECKING, Literal, Optional, Union
from typing import TYPE_CHECKING, Literal, Optional

from typing_extensions import Self

from mipac.core.models.poll import RawPoll
from mipac.models.lite.user import UserLite
from mipac.exception import NotExistRequiredData
from mipac.models.lite.user import UserLite

if TYPE_CHECKING:
from mipac.actions.note import NoteActions
Expand All @@ -21,7 +22,6 @@
'Poll',
'Follow',
'Header',
'Renote',
'NoteReaction',
)

Expand Down
2 changes: 2 additions & 0 deletions mipac/models/notification.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
from __future__ import annotations

from datetime import datetime
from typing import TYPE_CHECKING

from mipac.manager.client import ClientActions
from mipac.manager.reaction import ReactionManager
from mipac.models.lite.user import UserLite
Expand Down
6 changes: 3 additions & 3 deletions mipac/types/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
DriveRemoteChartPayload,
)
from mipac.types.chat import ChatPayload
from mipac.types.drive import IDriveFile, FolderPayload, PropertiesPayload
from mipac.types.drive import FolderPayload, IDriveFile, PropertiesPayload
from mipac.types.emoji import EmojiPayload
from mipac.types.instance import (
FeaturesPayload,
Expand All @@ -17,10 +17,10 @@
from mipac.types.note import (
GeoPayload,
INote,
INoteReaction,
INoteRequired,
IRenote,
IPoll,
INoteReaction
IRenote,
)
from mipac.types.page import (
AttachedFilePayload,
Expand Down
1 change: 1 addition & 0 deletions mipac/types/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ class ICustomEmojiLite(TypedDict):
name: str
url: str


class EmojiPayload(TypedDict):
id: Optional[str]
aliases: Optional[list[str]]
Expand Down
2 changes: 0 additions & 2 deletions mipac/types/endpoints.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import Literal


ENDPOINTS = Literal[
'/api/admin/abuse-user-reports',
'/api/admin/accounts/create',
Expand Down Expand Up @@ -311,4 +310,3 @@
'/api/users/stats',
'/api/version',
]

4 changes: 3 additions & 1 deletion mipac/types/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
'InstancePayload',
'OptionalInstance',
'OptionalMeta',
'IInstanceLite'
'IInstanceLite',
)


class IInstanceLite(TypedDict):
name: str
software_name: str
Expand All @@ -22,6 +23,7 @@ class IInstanceLite(TypedDict):
favicon_url: str
theme_color: str


class FeaturesPayload:
registration: bool
local_time_line: bool
Expand Down
3 changes: 1 addition & 2 deletions mipac/types/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,9 @@ class INote(INoteRequired, total=False):
is_hidden: bool
poll: IPoll


class INoteReaction(TypedDict):
id: str
created_at: str
user: IUserLite
type: str


3 changes: 1 addition & 2 deletions mipac/types/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"""

from __future__ import annotations
from typing import TYPE_CHECKING, TypedDict

from typing import TYPE_CHECKING, TypedDict

if TYPE_CHECKING:
from mipac.types.note import INote
Expand All @@ -25,4 +25,3 @@ class IReactionNf(Notification):
user: IUserLite
user_id: str
note: INote

1 change: 0 additions & 1 deletion mipac/types/user.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from __future__ import annotations
import string

from typing import Any, List, Literal, Optional, TypedDict

Expand Down

0 comments on commit ccb8c3b

Please sign in to comment.