diff --git a/pyproject.toml b/pyproject.toml index c1900d3..c13dcf0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -42,7 +42,6 @@ line-length = 120 [tool.ruff.lint] select = ["ALL"] ignore = [ - "ANN", # Annotations "D", # Docstrings "FIX", # TODO, FIXME and other messages "ERA001", # Commented out code diff --git a/src/signalblast/commands_strings.py b/src/signalblast/commands_strings.py index fbc90d8..ff5fb00 100644 --- a/src/signalblast/commands_strings.py +++ b/src/signalblast/commands_strings.py @@ -1,5 +1,6 @@ import inspect import re +from collections.abc import Iterator from dataclasses import dataclass @@ -7,13 +8,13 @@ class _IterableDataClass: _public_attr = None @classmethod - def _get_public_attributes(cls): - cls._public_attr = [] + def _get_public_attributes(cls) -> None: + cls._public_attr: list[str] = [] for attr, value in inspect.getmembers(cls): if not (attr.startswith("_") or inspect.ismethod(value)): cls._public_attr.append(value) - def __iter__(self): + def __iter__(self) -> Iterator[str]: if self._public_attr is None: self._get_public_attributes() diff --git a/src/signalblast/message_handler.py b/src/signalblast/message_handler.py index d110821..6009395 100644 --- a/src/signalblast/message_handler.py +++ b/src/signalblast/message_handler.py @@ -22,7 +22,7 @@ def empty_list_to_none(self, attachments: list[str] | None) -> list | None: return attachments - def delete_attachments(self, attachments: list[str] | None, link_previews: list[str] | None): + def delete_attachments(self, attachments: list[str] | None, link_previews: list[str] | None) -> None: if attachments is not None: for attachment in attachments: (self.attachments_folder / attachment).unlink() @@ -34,12 +34,12 @@ def delete_attachments(self, attachments: list[str] | None, link_previews: list[ @staticmethod def _compose_help_message(*, add_admin_commands: bool) -> str: - def _add_commands(message): + def _add_commands(message: str) -> str: for command_str in PublicCommandStrings: message += "\t" + command_str + "\n" return message - def _add_admin_commands(message): + def _add_admin_commands(message: str) -> str: for command_str, command_arg in zip(AdminCommandStrings, AdminCommandArgs, strict=False): message += "\t" + command_str + " " + command_arg + "\n" return message diff --git a/src/signalblast/users.py b/src/signalblast/users.py index 896e3c2..d53c306 100644 --- a/src/signalblast/users.py +++ b/src/signalblast/users.py @@ -4,6 +4,7 @@ from typing import TYPE_CHECKING if TYPE_CHECKING: + from collections.abc import Iterator from pathlib import Path @@ -23,7 +24,7 @@ async def remove(self, uuid: str) -> None: del self.data[uuid] await self.save_to_file() - async def save_to_file(self): + async def save_to_file(self) -> None: with self.save_path.open("w") as f: csv_writer = csv.DictWriter(f, fieldnames=[self._uuid_str, self._phone_number_str]) csv_writer.writeheader() @@ -42,13 +43,13 @@ async def _load_from_file(save_path: Path) -> Users: def get_phone_number(self, uuid: str) -> str | None: return self.data.get(uuid) - def __iter__(self): + def __iter__(self) -> Iterator[str | None]: yield from self.data - def __contains__(self, uuid: str): + def __contains__(self, uuid: str) -> bool: return uuid in self.data - def __len__(self): + def __len__(self) -> int: return len(self.data) @staticmethod diff --git a/src/signalblast/utils.py b/src/signalblast/utils.py index 2b3514c..9414cc0 100644 --- a/src/signalblast/utils.py +++ b/src/signalblast/utils.py @@ -39,7 +39,7 @@ def get_code_data_path() -> Path: def triggered(pattern: Pattern) -> Callable: def decorator_triggered(func: Callable) -> Callable: @functools.wraps(func) - async def wrapper_triggered(*args, **kwargs): + async def wrapper_triggered(*args, **kwargs) -> Callable: # noqa: ANN002, ANN003 c: ChatContext = args[1] text = c.message.text if not isinstance(text, str):