-
Notifications
You must be signed in to change notification settings - Fork 18
fix: update type hints #29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
| self.polling = False | ||
|
|
||
| self.command_prefixes: str | list[str] = command_prefixes | ||
|
|
@@ -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 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need default
|
||
|
|
||
| self.marker: int | None = None | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -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 | ||||||||||
|
||||||||||
| self.parent: Router | None = None # Parent bot of this router | |
| self.parent: Optional["Router"] = None # Parent bot of this router |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
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.
| 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) |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -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
|
||||||
| self.description: "str | None" = description | ||||||
|
|
@@ -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
|
||||||
|
|
||||||
| def __repr__(self): | ||||||
|
|
@@ -429,7 +429,7 @@ def __eq__(self, other): | |||||
| return False | ||||||
|
|
||||||
| @staticmethod | ||||||
| def from_json(data: dict) -> "MessageRecipient": | ||||||
| def from_json(data: dict) -> "MessageRecipient | None": | ||||||
|
||||||
| def from_json(data: dict) -> "MessageRecipient | None": | |
| def from_json(data: "dict | None") -> "MessageRecipient | None": |
Copilot
AI
Feb 9, 2026
There was a problem hiding this comment.
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
AI
Feb 9, 2026
There was a problem hiding this comment.
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
AI
Feb 9, 2026
There was a problem hiding this comment.
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).
| self.last_event_time: float | None = ( | |
| self.last_event_time: Optional[float] = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aiohttp.ClientSession | Noneis 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 orOptional[aiohttp.ClientSession](or raise the minimum supported Python version).