Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions aiomax/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(
super().__init__(case_sensitive)

self.access_token: str = access_token
self.session = None
self.session: aiohttp.ClientSession | None = None
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aiohttp.ClientSession | None is a PEP 604 union and will be evaluated at runtime; this raises on Python 3.9. Since the project targets 3.9+, use a quoted annotation or Optional[aiohttp.ClientSession] (or raise the minimum supported Python version).

Copilot uses AI. Check for mistakes.
self.polling = False

self.command_prefixes: str | list[str] = command_prefixes
Expand All @@ -76,7 +76,7 @@ def __init__(
self.username: str | None = None
self.name: str | None = None
self.description: str | None = None
self.bot_commands: list[BotCommand] = None
self.bot_commands: list[BotCommand] | None = None
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need default None here?
Looks like default should be [ ]

Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

list[BotCommand] | None is a PEP 604 union and will be evaluated at runtime; this raises on Python 3.9. Use a quoted annotation or Optional[list[BotCommand]] (or bump requires-python to 3.10+).

Copilot uses AI. Check for mistakes.

self.marker: int | None = None

Expand Down
2 changes: 1 addition & 1 deletion aiomax/router.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def __init__(
str, list[CommandHandler]
] = {} # commands in this router
self.case_sensitive: bool = case_sensitive
self.parent = None # Parent bot of this router
self.parent: Router | None = None # Parent bot of this router
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

self.parent: Router | None uses PEP 604 unions, which are evaluated at runtime and will raise on Python 3.9 (the project declares requires-python >= 3.9). Use a quoted annotation (e.g. "Router | None") or Optional[Router] to keep 3.9 compatibility (or bump the minimum Python version if 3.10+ is required).

Suggested change
self.parent: Router | None = None # Parent bot of this router
self.parent: Optional["Router"] = None # Parent bot of this router

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The inline comment says “Parent bot of this router”, but parent is typed/used as a parent router (and can be a Bot only in the root case). Update the comment to reflect what parent actually represents to avoid confusion when working with nested routers.

Suggested change
self.parent: Router | None = None # Parent bot of this router
self.parent: Router | None = None # Parent router in the hierarchy (may be the bot for the root router)

Copilot uses AI. Check for mistakes.
self.routers: list[Router] = []
self.filters: dict[str, list[Callable]] = {
"message_created": [],
Expand Down
34 changes: 17 additions & 17 deletions aiomax/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def __init__(
self.name: str = name
self.username: "str | None" = username
self.is_bot: bool = is_bot
self.last_activity_time: int = (
self.last_activity_time: float | None = (
last_activity_time / 1000 if last_activity_time else None
)
Comment on lines +41 to 43
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float | None is a PEP 604 union and will be evaluated at runtime; this raises on Python 3.9. Use a quoted annotation or Optional[float] here. Also, last_access_time is still annotated as int | None but is computed via / 1000, which produces a float—its annotation should be updated for consistency.

Copilot uses AI. Check for mistakes.
self.description: "str | None" = description
Expand All @@ -52,7 +52,7 @@ def __init__(
)
self.is_owner: "bool | None" = is_owner
self.is_admin: "bool | None" = is_admin
self.join_time: "int | None" = join_time / 1000 if join_time else None
self.join_time: "float | None" = join_time / 1000 if join_time else None
self.permissions: "list[str] | None" = permissions
Comment on lines 54 to 56
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float | None is a PEP 604 union and will be evaluated at runtime; this raises on Python 3.9. Use a quoted annotation or Optional[float] for join_time (or bump the minimum Python version).

Copilot uses AI. Check for mistakes.

def __repr__(self):
Expand Down Expand Up @@ -429,7 +429,7 @@ def __eq__(self, other):
return False

@staticmethod
def from_json(data: dict) -> "MessageRecipient":
def from_json(data: dict) -> "MessageRecipient | None":
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data can be None (the function explicitly handles that), but the parameter is typed as dict. Update the signature to accept dict | None (or equivalent) so callers like data.get(...) type-check cleanly.

Suggested change
def from_json(data: dict) -> "MessageRecipient | None":
def from_json(data: "dict | None") -> "MessageRecipient | None":

Copilot uses AI. Check for mistakes.
if data is None:
return None

Expand Down Expand Up @@ -523,7 +523,7 @@ def __init__(
self.markup: "list[Markup] | None" = markup

@staticmethod
def from_json(data: dict) -> "MessageBody":
def from_json(data: dict) -> "MessageBody | None":
if data is None:
return None
Comment on lines +526 to 528
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data can be None (the function explicitly handles that), but the parameter is typed as dict. Update the signature to accept dict | None (or equivalent) so callers like data.get(...) type-check cleanly.

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -552,7 +552,7 @@ def __init__(
self.chat_id: "int | None" = chat_id

@staticmethod
def from_json(data: dict) -> "LinkedMessage":
def from_json(data: dict) -> "LinkedMessage | None":
if data is None:
return None
Comment on lines +555 to 557
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data can be None (the function explicitly handles that), but the parameter is typed as dict. Update the signature to accept dict | None (or equivalent) so callers like data.get(...) type-check cleanly.

Copilot uses AI. Check for mistakes.

Expand Down Expand Up @@ -706,7 +706,7 @@ async def reply(
| buttons.KeyboardBuilder \
| None""" = None,
attachments: "list[Attachment] | Attachment | None" = None,
) -> "Message":
) -> "Message | None":
"""
Reply to this message.

Expand Down Expand Up @@ -742,7 +742,7 @@ async def edit(
| buttons.KeyboardBuilder \
| None""" = None,
attachments: "list[Attachment] | Attachment | None" = None,
) -> "Message":
) -> "Message | None":
"""
Edit a message

Expand Down Expand Up @@ -812,7 +812,7 @@ async def send(
| buttons.KeyboardBuilder \
| None""" = None,
attachments: "list[Attachment] | Attachment | None" = None,
) -> "Message":
) -> "Message | None":
"""
Send a message to the chat where bot was started.

Expand Down Expand Up @@ -1040,7 +1040,7 @@ def __init__(
self.chat_id: int = chat_id
self.type: str = type
self.status: str = status
self.last_event_time: int = (
self.last_event_time: float | None = (
Copy link

Copilot AI Feb 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

float | None is a PEP 604 union and will be evaluated at runtime; this raises on Python 3.9. Use a quoted annotation or Optional[float] for last_event_time (or bump the minimum Python version).

Suggested change
self.last_event_time: float | None = (
self.last_event_time: Optional[float] = (

Copilot uses AI. Check for mistakes.
last_event_time / 1000 if last_event_time else None
)
self.participants_count: int = participants_count
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def __init__(
payload: "str | None" = None,
):
self.bot = bot
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.callback_id: str = callback_id
self.message: "Message | None" = message
self.user: User = user
Expand All @@ -1115,7 +1115,7 @@ async def send(
| buttons.KeyboardBuilder \
| None""" = None,
attachments: "list[Attachment] | Attachment | None" = None,
) -> "Message":
) -> "Message | None":
"""
Send a message to the chat that contains the message
with the pressed button.
Expand Down Expand Up @@ -1155,7 +1155,7 @@ async def reply(
| buttons.KeyboardBuilder \
| None""" = None,
attachments: "list[Attachment] | Attachment | None" = None,
) -> "Message":
) -> "Message | None":
"""
Reply to the message with the button.

Expand Down Expand Up @@ -1283,7 +1283,7 @@ def __init__(
:param message_id: Message ID on which the button was
:param start_payload: Start payload specified by the button
"""
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.chat: Chat = chat
self.message_id: "str | None" = message_id
self.start_payload: "str | None" = start_payload
Expand Down Expand Up @@ -1321,7 +1321,7 @@ def __init__(
:param chat_id: ID of the chat the message was deleted in
:param user_id: ID of the user who deleted the message
"""
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.message: "Message | None" = message
self.message_id: "str | None" = message_id
self.chat_id: "int | None" = chat_id
Expand Down Expand Up @@ -1366,7 +1366,7 @@ def __init__(
:param chat_id: Chat ID that had its title edited.
:param title: New chat title
"""
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.user: User = user
self.chat_id: "int | None" = chat_id
self.title: "str | None" = title
Expand Down Expand Up @@ -1406,7 +1406,7 @@ def __init__(
:param is_channel: Whether the bot got added to / kicked
from a channel or not
"""
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.user: User = user
self.chat_id: "int | None" = chat_id
self.is_channel: bool = is_channel
Expand Down Expand Up @@ -1449,7 +1449,7 @@ def __init__(
:param initiator: User ID of the inviter / kicker,
if the user got invited by another user or kicked by an admin.
"""
self.timestamp: int = timestamp / 1000
self.timestamp: float = timestamp / 1000
self.user: User = user
self.chat_id: "int | None" = chat_id
self.is_channel: bool = is_channel
Expand Down
6 changes: 3 additions & 3 deletions aiomax/utils.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from inspect import signature
from typing import Callable, Literal
from typing import Any, Callable, Literal

import aiohttp

Expand All @@ -21,7 +21,7 @@ def get_message_body(
"""
Returns the body of the message as json.
"""
body = {"text": text, "format": format, "notify": notify}
body: dict[str, Any] = {"text": text, "format": format, "notify": notify}

# replying
if reply_to:
Expand Down Expand Up @@ -57,7 +57,7 @@ def get_message_body(
for at in attachments or []:
if not hasattr(at, "as_dict"):
raise exceptions.AiomaxException(
"This attachmentcannot be sent"
"This attachment cannot be sent"
)
body["attachments"].append(at.as_dict())

Expand Down
Loading