Skip to content

Commit

Permalink
chore: importの整理
Browse files Browse the repository at this point in the history
  • Loading branch information
yupix committed Dec 5, 2023
1 parent d089de3 commit b2b0a02
Show file tree
Hide file tree
Showing 20 changed files with 37 additions and 44 deletions.
3 changes: 1 addition & 2 deletions mipac/abstract/action.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@
from abc import ABC, abstractmethod
from typing import TYPE_CHECKING


if TYPE_CHECKING:
from mipac.manager.client import ClientManager
from mipac.http import HTTPClient
from mipac.manager.client import ClientManager


__all__ = ("AbstractAction",)
Expand Down
5 changes: 3 additions & 2 deletions mipac/actions/channel.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,22 @@
from __future__ import annotations

from typing import TYPE_CHECKING, AsyncGenerator, Literal

from typing_extensions import override

from mipac.abstract.action import AbstractAction
from mipac.file import MiFile
from mipac.http import HTTPClient, Route
from mipac.models.channel import Channel
from mipac.models.drive import File
from mipac.models.note import Note
from mipac.models.poll import MiPoll
from mipac.types.channel import IChannel
from mipac.types.note import INote, INoteVisibility
from mipac.types.reaction import IReactionAcceptance
from mipac.utils.format import remove_dict_missing
from mipac.utils.util import MISSING, credentials_required
from mipac.models.note import Note
from mipac.utils.pagination import Pagination
from mipac.utils.util import MISSING, credentials_required

if TYPE_CHECKING:
from mipac.client import ClientManager
Expand Down
2 changes: 1 addition & 1 deletion mipac/actions/drive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mipac.http import HTTPClient, Route
from mipac.models.drive import File
from mipac.models.note import Note
from mipac.types.drive import IFile, IDriveSort
from mipac.types.drive import IDriveSort, IFile
from mipac.types.note import INote
from mipac.utils.format import bool_to_string, remove_dict_missing
from mipac.utils.util import MISSING, credentials_required
Expand Down
2 changes: 1 addition & 1 deletion mipac/actions/drive/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

from typing import TYPE_CHECKING

from mipac.http import HTTPClient, Route
from mipac.abstract.action import AbstractAction
from mipac.http import HTTPClient, Route
from mipac.models.drive import File, Folder
from mipac.types.drive import IFolder
from mipac.utils.format import remove_dict_missing
Expand Down
2 changes: 1 addition & 1 deletion mipac/actions/federation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from mipac.errors.base import ParameterError
from mipac.http import HTTPClient, Route
from mipac.models.instance import FederationInstance
from mipac.models.user import UserDetailedNotMe, MeDetailed, packed_user
from mipac.models.user import MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.follow import IFederationFollower, IFederationFollowing
from mipac.types.instance import IFederationInstance, IFederationInstanceStat
from mipac.types.user import IUserDetailed
Expand Down
14 changes: 2 additions & 12 deletions mipac/actions/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,15 @@

from typing import TYPE_CHECKING, AsyncGenerator, Literal, Optional, overload

from mipac.config import config
from mipac.errors.base import NotExistRequiredData, ParameterError
from mipac.http import HTTPClient, Route
from mipac.models.clip import Clip
from mipac.models.lite.user import PartialUser
from mipac.models.note import Note
from mipac.models.user import (
Achievement,
MeDetailed,
UserDetailedNotMe,
packed_user,
)
from mipac.models.user import Achievement, MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.clip import IClip
from mipac.types.note import INote
from mipac.types.user import (
IMeDetailedSchema,
IUser,
is_partial_user,
)
from mipac.types.user import IMeDetailedSchema, IUser, is_partial_user
from mipac.utils.cache import cache
from mipac.utils.format import remove_dict_empty
from mipac.utils.pagination import Pagination
Expand Down
2 changes: 1 addition & 1 deletion mipac/manager/drive/files.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from mipac.abstract.manager import AbstractManager
from mipac.actions.drive.files import FileActions, ClientFileActions
from mipac.actions.drive.files import ClientFileActions, FileActions
from mipac.http import HTTPClient

if TYPE_CHECKING:
Expand Down
6 changes: 5 additions & 1 deletion mipac/manager/drive/folders.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,11 @@
from typing import TYPE_CHECKING

from mipac.abstract.manager import AbstractManager
from mipac.actions.drive.folders import ClientFileActionsInFolder, FolderActions, ClientFolderActions
from mipac.actions.drive.folders import (
ClientFileActionsInFolder,
ClientFolderActions,
FolderActions,
)
from mipac.http import HTTPClient

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion mipac/manager/invite.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING

from mipac.abstract.manager import AbstractManager
from mipac.actions.invite import InviteActions, ClientInviteActions
from mipac.actions.invite import ClientInviteActions, InviteActions
from mipac.http import HTTPClient

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion mipac/models/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from typing import TYPE_CHECKING

from mipac.abstract.model import AbstractModel
from mipac.models.user import UserDetailedNotMe, MeDetailed, packed_user
from mipac.models.user import MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.admin import (
IIndexStat,
IModerationLog,
Expand Down
4 changes: 2 additions & 2 deletions mipac/models/channel.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from __future__ import annotations
from datetime import datetime

from datetime import datetime
from typing import TYPE_CHECKING

from mipac.models.note import Note
from mipac.types.channel import IChannel
from mipac.utils.format import str_to_datetime

if TYPE_CHECKING:
from mipac.manager.channel import ClientChannelManager
from mipac.manager import ClientManager
from mipac.manager.channel import ClientChannelManager


class Channel:
Expand Down
2 changes: 1 addition & 1 deletion mipac/models/drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
if TYPE_CHECKING:
from mipac.manager.client import ClientManager
from mipac.manager.drive.files import ClientFileManager
from mipac.types import IFolder, IFile, IFileProperties
from mipac.manager.drive.folders import ClientFolderManager
from mipac.types import IFile, IFileProperties, IFolder


__all__ = ["FileProperties", "File", "Folder"]
Expand Down
1 change: 1 addition & 0 deletions mipac/models/lite/role.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from __future__ import annotations

from typing import TYPE_CHECKING, Generic, TypeVar

from mipac.types.roles import IPartialRole

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion mipac/models/lite/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from typing import TYPE_CHECKING, Generic, TypeVar

from mipac.models.lite.instance import LiteInstance
from mipac.types.user import IBadgeRole, IPartialUser, IUserOnlineStatus, IAvatarDecoration
from mipac.types.user import IAvatarDecoration, IBadgeRole, IPartialUser, IUserOnlineStatus
from mipac.utils.util import deprecated

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

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

if TYPE_CHECKING:
Expand Down
2 changes: 1 addition & 1 deletion mipac/models/roles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

from mipac.abstract.model import AbstractModel
from mipac.models.lite.role import PartialRole
from mipac.models.user import MeDetailed, UserDetailedNotMe, MeDetailed, packed_user
from mipac.models.user import MeDetailed, UserDetailedNotMe, packed_user
from mipac.types.roles import IMeRole, IRole, IRolePolicies, IRolePolicieValue, IRoleUser
from mipac.utils.format import str_to_datetime

Expand Down
20 changes: 10 additions & 10 deletions mipac/models/user.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,32 @@
from __future__ import annotations

from datetime import datetime
from typing import TYPE_CHECKING, TypeVar, Generic
from typing import TYPE_CHECKING, Generic, TypeVar

from mipac.types.meta import IPolicies
from mipac.abstract.model import AbstractModel
from mipac.models.announcement import Announcement
from mipac.models.lite.role import PartialRole
from mipac.models.lite.user import BadgeRole, PartialUser
from mipac.models.note import Note
from mipac.types.meta import IPolicies
from mipac.types.page import IPage
from mipac.types.user import (
EmailNotificationTypes,
IAchievement,
IBlockingUser,
IFfVisibility,
IMeDetailedOnlySchema,
IMeDetailedSchema,
ITwoFactorBackupCodesStock,
IUser,
IUserDetailedNotMeOnlySchema,
IUserDetailedNotMeSchema,
IUserField,
IUserNotify,
IUserRole,
is_me_detailed,
IUserDetailedNotMeSchema,
IMeDetailedOnlySchema,
ITwoFactorBackupCodesStock,
NotificationRecieveConfig,
EmailNotificationTypes,
IUserSecurityKey,
IMeDetailedSchema,
IUserDetailedNotMeOnlySchema,
NotificationRecieveConfig,
is_me_detailed,
is_user_detailed_not_me,
)
from mipac.utils.format import str_to_datetime
Expand Down
2 changes: 1 addition & 1 deletion mipac/types/announcement.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from typing import TypedDict, NotRequired
from typing import NotRequired, TypedDict


class IAnnouncement(TypedDict):
Expand Down
1 change: 0 additions & 1 deletion mipac/types/channel.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from typing import NotRequired, TypedDict


from mipac.types.note import INote


Expand Down
5 changes: 2 additions & 3 deletions mipac/utils/cache.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from functools import lru_cache
import functools
from functools import lru_cache, wraps
from typing import Any

DEFAULT_CACHE: dict[str, list[str]] = {}
Expand All @@ -19,7 +18,7 @@ def set_cache(group: str, key: str, value: Any):

def cache(group: str = "default", override: bool = False):
def decorator(func):
@functools.wraps(func)
@wraps(func)
async def wrapper(self, *args, **kwargs):
key = cache_key_builder(func, self, *args, **kwargs)
hit_item = DEFAULT_CACHE_VALUE.get(key)
Expand Down

0 comments on commit b2b0a02

Please sign in to comment.