mirror of https://github.com/coddrago/Heroku
Deepsource fixes
parent
7b0cd6e32d
commit
21d0b5fc45
|
@ -12,7 +12,6 @@ import asyncio
|
||||||
import logging
|
import logging
|
||||||
from telethon.hints import EntityLike
|
from telethon.hints import EntityLike
|
||||||
from telethon import TelegramClient
|
from telethon import TelegramClient
|
||||||
import copy
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
|
@ -386,11 +386,11 @@ def translatable_docstring(cls):
|
||||||
config_complete._old_ = cls.config_complete
|
config_complete._old_ = cls.config_complete
|
||||||
cls.config_complete = config_complete
|
cls.config_complete = config_complete
|
||||||
|
|
||||||
for command, func in get_commands(cls).items():
|
for command_, func in get_commands(cls).items():
|
||||||
cls.strings[f"_cmd_doc_{command}"] = inspect.getdoc(func)
|
cls.strings[f"_cmd_doc_{command_}"] = inspect.getdoc(func)
|
||||||
|
|
||||||
for inline_handler, func in get_inline_handlers(cls).items():
|
for inline_handler_, func in get_inline_handlers(cls).items():
|
||||||
cls.strings[f"_ihandle_doc_{inline_handler}"] = inspect.getdoc(func)
|
cls.strings[f"_ihandle_doc_{inline_handler_}"] = inspect.getdoc(func)
|
||||||
|
|
||||||
cls.strings["_cls_doc"] = inspect.getdoc(cls)
|
cls.strings["_cls_doc"] = inspect.getdoc(cls)
|
||||||
|
|
||||||
|
@ -416,8 +416,8 @@ def tag(*tags, **kwarg_tags):
|
||||||
• `in` - Capture only incoming events
|
• `in` - Capture only incoming events
|
||||||
• `only_messages` - Capture only messages (not join events)
|
• `only_messages` - Capture only messages (not join events)
|
||||||
• `editable` - Capture only messages, which can be edited (no forwards etc.)
|
• `editable` - Capture only messages, which can be edited (no forwards etc.)
|
||||||
• `no_media` - Capture only messages without media \ files
|
• `no_media` - Capture only messages without media and files
|
||||||
• `only_media` - Capture only messages with media \ files
|
• `only_media` - Capture only messages with media and files
|
||||||
• `only_photos` - Capture only messages with photos
|
• `only_photos` - Capture only messages with photos
|
||||||
• `only_videos` - Capture only messages with videos
|
• `only_videos` - Capture only messages with videos
|
||||||
• `only_audios` - Capture only messages with audios
|
• `only_audios` - Capture only messages with audios
|
||||||
|
@ -439,11 +439,11 @@ def tag(*tags, **kwarg_tags):
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def inner(func: callable):
|
def inner(func: callable):
|
||||||
for tag in tags:
|
for _tag in tags:
|
||||||
setattr(func, tag, True)
|
setattr(func, _tag, True)
|
||||||
|
|
||||||
for tag, value in kwarg_tags.items():
|
for _tag, value in kwarg_tags.items():
|
||||||
setattr(func, tag, value)
|
setattr(func, _tag, value)
|
||||||
|
|
||||||
return func
|
return func
|
||||||
|
|
||||||
|
@ -688,33 +688,33 @@ class Modules:
|
||||||
if getattr(instance, "__origin__", "") == "<core>":
|
if getattr(instance, "__origin__", "") == "<core>":
|
||||||
self._core_commands += list(map(lambda x: x.lower(), instance.commands))
|
self._core_commands += list(map(lambda x: x.lower(), instance.commands))
|
||||||
|
|
||||||
for command in instance.commands.copy():
|
for _command in instance.commands.copy():
|
||||||
# Restrict overwriting core modules' commands
|
# Restrict overwriting core modules' commands
|
||||||
if (
|
if (
|
||||||
command.lower() in self._core_commands
|
_command.lower() in self._core_commands
|
||||||
and getattr(instance, "__origin__", "") != "<core>"
|
and getattr(instance, "__origin__", "") != "<core>"
|
||||||
):
|
):
|
||||||
with contextlib.suppress(Exception):
|
with contextlib.suppress(Exception):
|
||||||
self.modules.remove(instance)
|
self.modules.remove(instance)
|
||||||
|
|
||||||
raise CoreOverwriteError(command=command)
|
raise CoreOverwriteError(command=_command)
|
||||||
|
|
||||||
# Verify that command does not already exist, or,
|
# Verify that command does not already exist, or,
|
||||||
# if it does, the command must be from the same class name
|
# if it does, the command must be from the same class name
|
||||||
if command.lower() in self.commands:
|
if _command.lower() in self.commands:
|
||||||
if (
|
if (
|
||||||
hasattr(instance.commands[command], "__self__")
|
hasattr(instance.commands[_command], "__self__")
|
||||||
and hasattr(self.commands[command], "__self__")
|
and hasattr(self.commands[_command], "__self__")
|
||||||
and instance.commands[command].__self__.__class__.__name__
|
and instance.commands[_command].__self__.__class__.__name__
|
||||||
!= self.commands[command].__self__.__class__.__name__
|
!= self.commands[_command].__self__.__class__.__name__
|
||||||
):
|
):
|
||||||
logger.debug(f"Duplicate command {command}")
|
logger.debug(f"Duplicate command {_command}")
|
||||||
logger.debug(f"Replacing command for {self.commands[command]}")
|
logger.debug(f"Replacing command for {self.commands[_command]}")
|
||||||
|
|
||||||
if not instance.commands[command].__doc__:
|
if not instance.commands[_command].__doc__:
|
||||||
logger.debug(f"Missing docs for {command}")
|
logger.debug(f"Missing docs for {_command}")
|
||||||
|
|
||||||
self.commands.update({command.lower(): instance.commands[command]})
|
self.commands.update({_command.lower(): instance.commands[_command]})
|
||||||
|
|
||||||
for alias, cmd in self.aliases.items():
|
for alias, cmd in self.aliases.items():
|
||||||
if cmd in instance.commands:
|
if cmd in instance.commands:
|
||||||
|
@ -757,7 +757,7 @@ class Modules:
|
||||||
with contextlib.suppress(AttributeError):
|
with contextlib.suppress(AttributeError):
|
||||||
_hikka_client_id_logging_tag = copy.copy(self.client.tg_id)
|
_hikka_client_id_logging_tag = copy.copy(self.client.tg_id)
|
||||||
|
|
||||||
for watcher in _get_members(
|
for _watcher in _get_members(
|
||||||
instance,
|
instance,
|
||||||
"watcher",
|
"watcher",
|
||||||
"is_watcher",
|
"is_watcher",
|
||||||
|
@ -771,7 +771,7 @@ class Modules:
|
||||||
if (
|
if (
|
||||||
hasattr(existing_watcher, "__self__")
|
hasattr(existing_watcher, "__self__")
|
||||||
and f"{existing_watcher.__self__.__class__.__name__}.{existing_watcher.__name__}"
|
and f"{existing_watcher.__self__.__class__.__name__}.{existing_watcher.__name__}"
|
||||||
== f"{watcher.__self__.__class__.__name__}.{watcher.__name__}"
|
== f"{_watcher.__self__.__class__.__name__}.{_watcher.__name__}"
|
||||||
)
|
)
|
||||||
),
|
),
|
||||||
None,
|
None,
|
||||||
|
@ -781,7 +781,7 @@ class Modules:
|
||||||
logger.debug(f"Removing watcher for update {existing_watcher}")
|
logger.debug(f"Removing watcher for update {existing_watcher}")
|
||||||
self.watchers.remove(existing_watcher)
|
self.watchers.remove(existing_watcher)
|
||||||
|
|
||||||
self.watchers += [watcher]
|
self.watchers += [_watcher]
|
||||||
|
|
||||||
def _lookup(self, modname: str):
|
def _lookup(self, modname: str):
|
||||||
return next(
|
return next(
|
||||||
|
@ -1047,7 +1047,7 @@ class Modules:
|
||||||
def _raise(e: Exception):
|
def _raise(e: Exception):
|
||||||
if suspend_on_error:
|
if suspend_on_error:
|
||||||
raise SelfSuspend("Required library is not available or is corrupted.")
|
raise SelfSuspend("Required library is not available or is corrupted.")
|
||||||
else:
|
|
||||||
raise e
|
raise e
|
||||||
|
|
||||||
if not utils.check_url(url):
|
if not utils.check_url(url):
|
||||||
|
@ -1239,15 +1239,15 @@ class Modules:
|
||||||
|
|
||||||
return lib_obj
|
return lib_obj
|
||||||
|
|
||||||
def dispatch(self, command: str) -> tuple:
|
def dispatch(self, _command: str) -> tuple:
|
||||||
"""Dispatch command to appropriate module"""
|
"""Dispatch command to appropriate module"""
|
||||||
return next(
|
return next(
|
||||||
(
|
(
|
||||||
(cmd, self.commands[cmd.lower()])
|
(cmd, self.commands[cmd.lower()])
|
||||||
for cmd in [command, self.aliases.get(command.lower(), None)]
|
for cmd in [_command, self.aliases.get(_command.lower())]
|
||||||
if cmd and cmd.lower() in self.commands
|
if cmd and cmd.lower() in self.commands
|
||||||
),
|
),
|
||||||
(command, None),
|
(_command, None),
|
||||||
)
|
)
|
||||||
|
|
||||||
def send_config(self, skip_hook: bool = False):
|
def send_config(self, skip_hook: bool = False):
|
||||||
|
@ -1487,21 +1487,21 @@ class Modules:
|
||||||
to_remove += [module.watcher]
|
to_remove += [module.watcher]
|
||||||
|
|
||||||
logger.debug(f"{to_remove=}, {worked=}")
|
logger.debug(f"{to_remove=}, {worked=}")
|
||||||
for watcher in self.watchers.copy():
|
for _watcher in self.watchers.copy():
|
||||||
if watcher in to_remove:
|
if _watcher in to_remove:
|
||||||
logger.debug(f"Removing {watcher=} for unload")
|
logger.debug(f"Removing {_watcher=} for unload")
|
||||||
self.watchers.remove(watcher)
|
self.watchers.remove(_watcher)
|
||||||
|
|
||||||
aliases_to_remove = []
|
aliases_to_remove = []
|
||||||
|
|
||||||
for name, command in self.commands.copy().items():
|
for name, _command in self.commands.copy().items():
|
||||||
if command in to_remove:
|
if _command in to_remove:
|
||||||
logger.debug(f"Removing {command=} for unload")
|
logger.debug(f"Removing {_command=} for unload")
|
||||||
del self.commands[name]
|
del self.commands[name]
|
||||||
aliases_to_remove.append(name)
|
aliases_to_remove.append(name)
|
||||||
|
|
||||||
for alias, command in self.aliases.copy().items():
|
for alias, _command in self.aliases.copy().items():
|
||||||
if command in aliases_to_remove:
|
if _command in aliases_to_remove:
|
||||||
del self.aliases[alias]
|
del self.aliases[alias]
|
||||||
|
|
||||||
return worked
|
return worked
|
||||||
|
|
|
@ -190,7 +190,7 @@ class HelpMod(loader.Module):
|
||||||
utils.escape_html(name)
|
utils.escape_html(name)
|
||||||
if not hasattr(module, "__version__")
|
if not hasattr(module, "__version__")
|
||||||
else (
|
else (
|
||||||
f"{utils.escape_html(name)} (v{'{}.{}.{}'.format(*module.__version__)})"
|
f"{utils.escape_html(name)} (v{module.__version__[0]}.{module.__version__[1]}.{module.__version__[2]})"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -1026,6 +1026,7 @@ def mime_type(message: Message) -> str:
|
||||||
|
|
||||||
init_ts = time.perf_counter()
|
init_ts = time.perf_counter()
|
||||||
|
|
||||||
|
|
||||||
# GeekTG Compatibility
|
# GeekTG Compatibility
|
||||||
def get_git_info():
|
def get_git_info():
|
||||||
# https://github.com/GeekTG/Friendly-Telegram/blob/master/friendly-telegram/utils.py#L133
|
# https://github.com/GeekTG/Friendly-Telegram/blob/master/friendly-telegram/utils.py#L133
|
||||||
|
|
Loading…
Reference in New Issue