Skip to content

Commit

Permalink
feat!: AbstractModelを廃止
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Jan 5, 2024
1 parent 939b749 commit 3158d0e
Show file tree
Hide file tree
Showing 26 changed files with 76 additions and 115 deletions.
1 change: 0 additions & 1 deletion mipac/abstract/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from .action import *
from .manager import *
from .model import *
16 changes: 0 additions & 16 deletions mipac/abstract/model.py

This file was deleted.

3 changes: 1 addition & 2 deletions mipac/models/ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import TYPE_CHECKING, Literal

from mipac.abstract.model import AbstractModel
from mipac.types.ads import IAd
from mipac.utils.format import str_to_datetime

Expand All @@ -12,7 +11,7 @@
from mipac.manager.client import ClientManager


class Ad(AbstractModel):
class Ad:
def __init__(self, ad_data: IAd, *, client: ClientManager) -> None:
self.__ad_data: IAd = ad_data
self.__client: ClientManager = client
Expand Down
15 changes: 7 additions & 8 deletions mipac/models/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.user import MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.admin import (
IIndexStat,
Expand All @@ -21,7 +20,7 @@
from mipac.manager.client import ClientManager


class UserIP(AbstractModel):
class UserIP:
def __init__(self, user_ip: IUserIP) -> None:
self.__user_ip: IUserIP = user_ip

Expand Down Expand Up @@ -65,7 +64,7 @@ def indexdef(self) -> str:
return self.__index_stat["indexdef"]


class ModerationLog(AbstractModel):
class ModerationLog:
def __init__(self, moderation_log: IModerationLog, *, client: ClientManager) -> None:
self.__moderation_log: IModerationLog = moderation_log
self.__client: ClientManager = client
Expand Down Expand Up @@ -101,7 +100,7 @@ def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)


class ServerInfoCpu(AbstractModel):
class ServerInfoCpu:
def __init__(self, server_info_cpu: IServerInfoCpu) -> None:
self.__server_info_cpu = server_info_cpu

Expand All @@ -114,7 +113,7 @@ def cores(self) -> int:
return self.__server_info_cpu["cores"]


class ServerInfoMem(AbstractModel):
class ServerInfoMem:
def __init__(self, server_info_mem: IServerInfoMem) -> None:
self.__server_info_mem = server_info_mem

Expand All @@ -123,7 +122,7 @@ def total(self) -> int:
return self.__server_info_mem["total"]


class ServerInfoFs(AbstractModel):
class ServerInfoFs:
def __init__(self, server_info_fs: IServerInfoFs) -> None:
self.__server_info_fs = server_info_fs

Expand All @@ -136,7 +135,7 @@ def used(self) -> int:
return self.__server_info_fs["used"]


class ServerInfoNet(AbstractModel):
class ServerInfoNet:
def __init__(self, server_info_net: IServerInfoNet) -> None:
self.__server_info_net = server_info_net

Expand All @@ -145,7 +144,7 @@ def interface(self) -> str:
return self.__server_info_net["interface"]


class ServerInfo(AbstractModel):
class ServerInfo:
def __init__(self, server_info: IServerInfo) -> None:
self.__server_info = server_info

Expand Down
3 changes: 1 addition & 2 deletions mipac/models/antenna.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.types.antenna import IAntenna, IAntennaReceiveSource
from mipac.utils.format import str_to_datetime

Expand All @@ -12,7 +11,7 @@
from mipac.manager.client import ClientManager


class Antenna(AbstractModel):
class Antenna:
def __init__(self, antenna: IAntenna, *, client: ClientManager) -> None:
self.__antenna: IAntenna = antenna
self.__client: ClientManager = client
Expand Down
9 changes: 4 additions & 5 deletions mipac/models/chart.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
from mipac.abstract.model import AbstractModel
from mipac.types.chart import IActiveUsersChart, IDriveChart, IDriveLocalChart, IDriveRemoteChart


class ActiveUsersChart(AbstractModel):
class ActiveUsersChart:
__slots__ = ("__data",)

def __init__(self, data: IActiveUsersChart):
Expand Down Expand Up @@ -45,7 +44,7 @@ def registered_outside_year(self) -> list[int]:
return self.__data["registered_outside_year"]


class DriveLocalChart(AbstractModel):
class DriveLocalChart:
__slots__ = ("__data",)

def __init__(self, data: IDriveLocalChart):
Expand Down Expand Up @@ -76,7 +75,7 @@ def dec_size(self) -> list[int]:
return self.__data["dec_size"]


class DriveRemoteChart(AbstractModel):
class DriveRemoteChart:
__slots__ = ("__data",)

def __init__(self, data: IDriveRemoteChart):
Expand Down Expand Up @@ -107,7 +106,7 @@ def dec_size(self) -> list[int]:
return self.__data["dec_size"]


class DriveChart(AbstractModel):
class DriveChart:
__slots__ = ("__data",)

def __init__(self, data: IDriveChart):
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/clip.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.user import PartialUser
from mipac.types.clip import IClip

Expand All @@ -11,7 +10,7 @@
from mipac.manager.clip import ClientClipManager


class Clip(AbstractModel):
class Clip:
def __init__(self, raw_clip: IClip, *, client: ClientManager) -> None:
self.__clip: IClip = raw_clip
self.__client: ClientManager = client
Expand Down
7 changes: 3 additions & 4 deletions mipac/models/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.user import PartialUser
from mipac.types.drive import IDriveStatus

Expand Down Expand Up @@ -44,7 +43,7 @@ def usage(self) -> int:
return self.__raw_drive_status["usage"]


class FileProperties(AbstractModel):
class FileProperties:
def __init__(self, raw_properties: IFileProperties) -> None:
self.__raw_properties: IFileProperties = raw_properties

Expand All @@ -65,7 +64,7 @@ def avg_color(self) -> str | None:
return self.__raw_properties.get("avg_color")


class Folder(AbstractModel):
class Folder:
def __init__(self, raw_folder: IFolder, client: ClientManager):
self.__raw_folder: IFolder = raw_folder
self.__client: ClientManager = client
Expand Down Expand Up @@ -113,7 +112,7 @@ def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)


class File(AbstractModel):
class File:
def __init__(self, raw_file: IFile, *, client: ClientManager):
self.__raw_file: IFile = raw_file
self.__client: ClientManager = client
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/follow.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.user import PartialUser
from mipac.types.follow import IFollowRequest

Expand All @@ -11,7 +10,7 @@
from mipac.manager.follow import FollowRequestManager


class FollowRequest(AbstractModel):
class FollowRequest:
def __init__(self, follow_request: IFollowRequest, *, client: ClientManager) -> None:
self.__follow_request = follow_request
self.__client = client
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/instance.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.types.instance import IFederationInstance

if TYPE_CHECKING:
from mipac.client import ClientManager


class FederationInstance(AbstractModel):
class FederationInstance:
def __init__(self, instance: IFederationInstance, *, client: ClientManager) -> None:
self.__instance: IFederationInstance = instance
self.__client: ClientManager = client
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/lite/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.config import config
from mipac.types.emoji import ICustomEmojiLite

if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class PartialCustomEmoji(AbstractModel):
class PartialCustomEmoji:
def __init__(self, emoji: ICustomEmojiLite, *, client: ClientManager) -> None:
self.__emoji = emoji
self.__client: ClientManager = client
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/lite/instance.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
from __future__ import annotations

from mipac.abstract.model import AbstractModel
from mipac.types.instance import IInstanceLite


class LiteInstance(AbstractModel):
class LiteInstance:
def __init__(self, instance: IInstanceLite) -> None:
self.__instance: IInstanceLite = instance

Expand Down
3 changes: 1 addition & 2 deletions mipac/models/lite/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.ad import PartialAd
from mipac.types.meta import IPartialMeta, IPolicies

if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class Policies(AbstractModel):
class Policies:
def __init__(self, raw_policies: IPolicies) -> None:
self.__raw_policies: IPolicies = raw_policies

Expand Down
5 changes: 2 additions & 3 deletions mipac/models/meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.meta import PartialMeta
from mipac.types.meta import (
IAdminMeta,
Expand All @@ -16,7 +15,7 @@
from mipac.manager.client import ClientManager


class Features(AbstractModel):
class Features:
def __init__(self, raw_features: IFeatures) -> None:
self.__raw_features = raw_features

Expand Down Expand Up @@ -78,7 +77,7 @@ def proxy_account_name(self) -> str:
return self._raw_meta["proxy_account_name"]


class AdminMeta(AbstractModel):
class AdminMeta:
def __init__(self, raw_meta: IAdminMeta, *, client: ClientManager) -> None:
self.__raw_meta: IAdminMeta = raw_meta
self.__client: ClientManager = client
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/mute.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@

from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.user import MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.mute import IMuteUser

if TYPE_CHECKING:
from mipac.manager.client import ClientManager


class MuteUser(AbstractModel):
class MuteUser:
def __init__(self, data: IMuteUser, *, client: ClientManager) -> None:
self.__data: IMuteUser = data
self.__client: ClientManager = client
Expand Down
9 changes: 4 additions & 5 deletions mipac/models/note.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.drive import File
from mipac.models.lite.user import PartialUser
from mipac.models.poll import Poll
Expand Down Expand Up @@ -36,7 +35,7 @@
)


class NoteState(AbstractModel):
class NoteState:
def __init__(self, data: INoteState) -> None:
self.__data: INoteState = data

Expand All @@ -49,7 +48,7 @@ def is_muted_thread(self) -> bool:
return self.__data["is_muted_thread"]


class NoteDeleted(AbstractModel):
class NoteDeleted:
def __init__(self, data: INoteUpdated[INoteUpdatedDelete]) -> None:
self.__data = data

Expand All @@ -74,7 +73,7 @@ def __init__(self, data):
self.type = data.get("type")


class NoteReaction(AbstractModel):
class NoteReaction:
__slots__ = ("__reaction", "__client")

def __init__(self, raw_reaction: INoteReaction, *, client: ClientManager):
Expand Down Expand Up @@ -631,7 +630,7 @@ def __ne__(self, __value: object) -> bool:
return not self.__eq__(__value)


class NoteTranslateResult(AbstractModel):
class NoteTranslateResult:
"""
NoteTranslateResult
Expand Down
3 changes: 1 addition & 2 deletions mipac/models/notification.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
from datetime import datetime
from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.lite.user import PartialUser
from mipac.models.note import Note

Expand All @@ -20,7 +19,7 @@
)


class Notification(AbstractModel):
class Notification:
def __init__(
self,
notification: INotification,
Expand Down
Loading

0 comments on commit 3158d0e

Please sign in to comment.