Removed legacy usage of Union[]
This commit is contained in:
@@ -5,7 +5,7 @@ from datetime import datetime, timedelta
|
||||
from os import cpu_count, getpid
|
||||
from pathlib import Path
|
||||
from time import time
|
||||
from typing import Any, Dict, List, Union
|
||||
from typing import Any, Dict, List
|
||||
|
||||
from typing_extensions import override
|
||||
|
||||
@@ -48,22 +48,22 @@ class PyroClient(Client):
|
||||
def __init__(
|
||||
self,
|
||||
name: str = "bot_client",
|
||||
owner: Union[int, None] = None,
|
||||
config: Union[Dict[str, Any], None] = None,
|
||||
config_path: Union[str, Path] = Path("config.json"),
|
||||
api_id: Union[int, None] = None,
|
||||
api_hash: Union[str, None] = None,
|
||||
bot_token: Union[str, None] = None,
|
||||
owner: int | None = None,
|
||||
config: Dict[str, Any] | None = None,
|
||||
config_path: str | Path = Path("config.json"),
|
||||
api_id: int | None = None,
|
||||
api_hash: str | None = None,
|
||||
bot_token: str | None = None,
|
||||
workers: int = min(32, cpu_count() + 4),
|
||||
locales_root: Union[str, Path, None] = None,
|
||||
locales_root: str | Path | None = None,
|
||||
plugins_root: str = "plugins",
|
||||
plugins_exclude: Union[List[str], None] = None,
|
||||
plugins_exclude: List[str] | None = None,
|
||||
sleep_threshold: int = 120,
|
||||
max_concurrent_transmissions: int = 1,
|
||||
commands_source: Union[Dict[str, dict], None] = None,
|
||||
scoped_commands: Union[bool, None] = None,
|
||||
commands_source: Dict[str, dict] | None = None,
|
||||
scoped_commands: bool | None = None,
|
||||
i18n_bot_info: bool = False,
|
||||
scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = None,
|
||||
scheduler: AsyncIOScheduler | BackgroundScheduler | None = None,
|
||||
**kwargs,
|
||||
):
|
||||
if config is None:
|
||||
@@ -113,7 +113,7 @@ class PyroClient(Client):
|
||||
self.in_all_locales = self.bot_locale.in_all_locales
|
||||
self.in_every_locale = self.bot_locale.in_every_locale
|
||||
|
||||
self.scheduler: Union[AsyncIOScheduler, BackgroundScheduler, None] = scheduler
|
||||
self.scheduler: AsyncIOScheduler | BackgroundScheduler | None = scheduler
|
||||
|
||||
self.scopes_placeholders: Dict[str, int] = {"owner": self.owner}
|
||||
|
||||
@@ -238,7 +238,7 @@ class PyroClient(Client):
|
||||
except SystemExit as exc:
|
||||
raise SystemExit("Bot has been shut down, this is not an application error!") from exc
|
||||
|
||||
async def collect_commands(self) -> Union[List[CommandSet], None]:
|
||||
async def collect_commands(self) -> List[CommandSet] | None:
|
||||
"""Gather list of the bot's commands
|
||||
|
||||
### Returns:
|
||||
@@ -338,7 +338,7 @@ class PyroClient(Client):
|
||||
command,
|
||||
)
|
||||
|
||||
async def register_commands(self, command_sets: Union[List[CommandSet], None] = None) -> None:
|
||||
async def register_commands(self, command_sets: List[CommandSet] | None = None) -> None:
|
||||
"""Register commands stored in bot's 'commands' attribute"""
|
||||
|
||||
if command_sets is None:
|
||||
@@ -365,7 +365,7 @@ class PyroClient(Client):
|
||||
language_code=command_set.language_code,
|
||||
)
|
||||
|
||||
async def remove_commands(self, command_sets: Union[List[CommandSet], None] = None) -> None:
|
||||
async def remove_commands(self, command_sets: List[CommandSet] | None = None) -> None:
|
||||
"""Remove commands stored in bot's 'commands' attribute"""
|
||||
|
||||
if command_sets is None:
|
||||
|
@@ -1,5 +1,5 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import List, Union
|
||||
from typing import List
|
||||
|
||||
try:
|
||||
from pyrogram.types import (
|
||||
@@ -13,9 +13,7 @@ try:
|
||||
BotCommandScopeDefault,
|
||||
)
|
||||
except ImportError as exc:
|
||||
raise ImportError(
|
||||
"You need to install libbot[pyrogram] in order to use this class."
|
||||
) from exc
|
||||
raise ImportError("You need to install libbot[pyrogram] in order to use this class.") from exc
|
||||
|
||||
|
||||
@dataclass
|
||||
@@ -23,13 +21,13 @@ class CommandSet:
|
||||
"""Command stored in PyroClient's 'commands' attribute"""
|
||||
|
||||
commands: List[BotCommand]
|
||||
scope: Union[
|
||||
BotCommandScopeDefault,
|
||||
BotCommandScopeAllPrivateChats,
|
||||
BotCommandScopeAllGroupChats,
|
||||
BotCommandScopeAllChatAdministrators,
|
||||
BotCommandScopeChat,
|
||||
BotCommandScopeChatAdministrators,
|
||||
BotCommandScopeChatMember,
|
||||
] = BotCommandScopeDefault
|
||||
scope: (
|
||||
BotCommandScopeDefault
|
||||
| BotCommandScopeAllPrivateChats
|
||||
| BotCommandScopeAllGroupChats
|
||||
| BotCommandScopeAllChatAdministrators
|
||||
| BotCommandScopeChat
|
||||
| BotCommandScopeChatAdministrators
|
||||
| BotCommandScopeChatMember
|
||||
) = BotCommandScopeDefault
|
||||
language_code: str = ""
|
||||
|
Reference in New Issue
Block a user