Skip to content

Commit

Permalink
chore(lint): format with ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
HsiangNianian committed Mar 2, 2024
1 parent 81de1d6 commit 5db979b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
7 changes: 3 additions & 4 deletions iamai/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,7 @@ class Bot:
plugin_state: Dict[str, Any]
global_state: Dict[Any, Any]

_condition: (
asyncio.Condition
) # Condition used to handle get # pyright: ignore[reportUninitializedInstanceVariable]
_condition: asyncio.Condition # Condition used to handle get # pyright: ignore[reportUninitializedInstanceVariable]
_current_event: Optional[Event[Any]] # Event currently pending

_restart_flag: bool # Restart flag
Expand Down Expand Up @@ -769,7 +767,7 @@ def load_plugins(
"""Load the plugin.
Args:
*plugins: ``Plugin`` class, plugin module name or plug-in module file path.
*plugins: ``Plugin`` class, plugin module name or plug-in module file path.
Type can be ``Type[Plugin]``, ``str`` or ``pathlib.Path``.
If it is ``Type[Plugin]``, it will be loaded as a plug-in class.
If it is of type ``str``, it will be loaded as the plug-in module name, and the format is the same as the Python ``import`` statement.
Expand All @@ -780,6 +778,7 @@ def load_plugins(
self._extend_plugins.extend(plugins)

return self._load_plugins(*plugins)

def _load_plugins_from_dirs(self, *dirs: Path) -> None:
"""Load plug-ins from the directory. Plug-ins in modules starting with ``_`` will not be imported. The path can be a relative path or an absolute path.
Expand Down
13 changes: 7 additions & 6 deletions iamai/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ class MessageSegment(ABC, BaseModel, Mapping[str, Any], Generic[MessageT]):
Attributes:
type: message field type.
data: message field content.
"""
"""

type: str
data: Dict[str, Any] = Field(default_factory=dict)
Expand All @@ -357,7 +357,7 @@ def from_str(cls, msg: str) -> Self:
Returns:
Message fields converted by ``str``.
"""
"""

@classmethod
def from_mapping(cls, msg: Mapping[Any, Any]) -> Self:
Expand Down Expand Up @@ -458,16 +458,17 @@ def __eq__(self, other: object) -> bool:
and self.type == other.type
and self.data == other.data
)

def __ne__(self, other: object) -> bool:
"""Determine whether they are not equal.
"""Determine whether they are not equal.
Args:
other: other objects.
Returns:
Whether they are not equal.
"""
return not self.__eq__(other)
return not self.__eq__(other)

def __add__(self, other: Any) -> MessageT:
"""Method for adding custom message fields to other objects.
Expand Down Expand Up @@ -508,9 +509,9 @@ def items(self) -> ItemsView[str, Any]:
return self.data.items()

def is_text(self) -> bool:
""" is a plain text message field.
"""is a plain text message field.
Returns:
Whether it is a plain text message field.
"""
return self.type == "text"
return self.type == "text"
4 changes: 2 additions & 2 deletions iamai/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ async def sync_ctx_manager_wrapper(


def wrap_get_func(
func: Optional[Callable[[EventT], Union[bool, Awaitable[bool]]]]
func: Optional[Callable[[EventT], Union[bool, Awaitable[bool]]]],
) -> Callable[[EventT], Awaitable[bool]]:
"""Wrap the parameters accepted by the ``get()`` function into an asynchronous function.
Expand All @@ -252,7 +252,7 @@ def wrap_get_func(
else: # pragma: no cover

def get_annotations(
obj: Union[Callable[..., object], Type[Any], ModuleType]
obj: Union[Callable[..., object], Type[Any], ModuleType],
) -> Dict[str, Any]:
"""Compute the annotation dictionary of an object.
Expand Down

0 comments on commit 5db979b

Please sign in to comment.