diff --git a/royalnet/audio/youtubedl.py b/royalnet/audio/youtubedl.py index d397ccb2..523e07de 100644 --- a/royalnet/audio/youtubedl.py +++ b/royalnet/audio/youtubedl.py @@ -2,7 +2,6 @@ import typing import logging as _logging import os from youtube_dl import YoutubeDL -from contextlib import contextmanager log = _logging.getLogger(__name__) diff --git a/royalnet/bots/telegram.py b/royalnet/bots/telegram.py index d7b76b18..f7238cdd 100644 --- a/royalnet/bots/telegram.py +++ b/royalnet/bots/telegram.py @@ -2,13 +2,12 @@ import telegram import asyncio import typing import logging as _logging -import sys from .generic import GenericBot from ..commands import NullCommand from ..utils import asyncify, Call, Command from ..error import UnregisteredError, InvalidConfigError -from ..network import RoyalnetLink, Message, RequestError, RoyalnetConfig -from ..database import Alchemy, relationshiplinkchain, DatabaseConfig +from ..network import Message, RoyalnetConfig +from ..database import DatabaseConfig loop = asyncio.get_event_loop() log = _logging.getLogger(__name__) diff --git a/royalnet/commands/diario.py b/royalnet/commands/diario.py index 98859009..d960dbd6 100644 --- a/royalnet/commands/diario.py +++ b/royalnet/commands/diario.py @@ -100,12 +100,19 @@ class DiarioCommand(Command): message: telegram.Message = update.message reply: telegram.Message = message.reply_to_message creator = await call.get_author() + # noinspection PyUnusedLocal quoted_account: typing.Optional[call.alchemy.Telegram] + # noinspection PyUnusedLocal quoted: typing.Optional[str] + # noinspection PyUnusedLocal text: typing.Optional[str] + # noinspection PyUnusedLocal context: typing.Optional[str] + # noinspection PyUnusedLocal timestamp: datetime.datetime + # noinspection PyUnusedLocal media_url: typing.Optional[str] + # noinspection PyUnusedLocal spoiler: bool if creator is None: await call.reply("⚠️ Devi essere registrato a Royalnet per usare questo comando!") diff --git a/royalnet/commands/play.py b/royalnet/commands/play.py index 07e77a42..21509533 100644 --- a/royalnet/commands/play.py +++ b/royalnet/commands/play.py @@ -49,5 +49,5 @@ class PlayCommand(Command): @classmethod async def common(cls, call: Call): guild, url = call.args.match(r"(?:\[(.+)])?\s*(.+)") - response: RequestSuccessful = await call.net_request(PlayMessage(url, guild), "discord") + await call.net_request(PlayMessage(url, guild), "discord") await call.reply(f"✅ Richiesta la riproduzione di [c]{url}[/c].") diff --git a/royalnet/commands/reminder.py b/royalnet/commands/reminder.py index bfc90adc..cd2a7232 100644 --- a/royalnet/commands/reminder.py +++ b/royalnet/commands/reminder.py @@ -13,9 +13,8 @@ class ReminderCommand(Command): @classmethod async def common(cls, call: Call): date_str, reminder_text = call.args.match(r"\[ *(.+?) *] *(.+?) *$") - date: typing.Optional[datetime.datetime] try: - date = dateparser.parse(date_str) + date: typing.Optional[datetime.datetime] = dateparser.parse(date_str) except OverflowError: date = None if date is None: diff --git a/royalnet/commands/skip.py b/royalnet/commands/skip.py index 7534588a..8492ca51 100644 --- a/royalnet/commands/skip.py +++ b/royalnet/commands/skip.py @@ -3,7 +3,6 @@ import discord from ..network import Message, RequestSuccessful from ..utils import Command, Call, NetworkHandler from ..error import TooManyFoundError, NoneFoundError -from ..audio import RoyalPCMAudio if typing.TYPE_CHECKING: from ..bots import DiscordBot @@ -45,5 +44,5 @@ class SkipCommand(Command): @classmethod async def common(cls, call: Call): guild, = call.args.match(r"(?:\[(.+)])?") - response: RequestSuccessful = await call.net_request(SkipMessage(guild), "discord") + await call.net_request(SkipMessage(guild), "discord") await call.reply(f"✅ Richiesta lo skip della canzone attuale..") diff --git a/royalnet/commands/summon.py b/royalnet/commands/summon.py index d34049b7..477d6949 100644 --- a/royalnet/commands/summon.py +++ b/royalnet/commands/summon.py @@ -53,9 +53,8 @@ class SummonCommand(Command): channel_name: str = call.args.optional(0) if channel_name: guild: typing.Optional[discord.Guild] = message.guild - channels: typing.List[discord.abc.GuildChannel] if guild is not None: - channels = guild.channels + channels: typing.List[discord.abc.GuildChannel] = guild.channels else: channels = bot.get_all_channels() matching_channels: typing.List[discord.VoiceChannel] = [] diff --git a/royalnet/database/alchemy.py b/royalnet/database/alchemy.py index d99eea7b..e17d4041 100644 --- a/royalnet/database/alchemy.py +++ b/royalnet/database/alchemy.py @@ -5,6 +5,7 @@ from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from contextlib import contextmanager, asynccontextmanager from ..utils import asyncify +# noinspection PyUnresolvedReferences from ..error import InvalidConfigError loop = asyncio.get_event_loop() diff --git a/royalnet/database/tables/activekvgroup.py b/royalnet/database/tables/activekvgroup.py index d8918bc4..c132b1dc 100644 --- a/royalnet/database/tables/activekvgroup.py +++ b/royalnet/database/tables/activekvgroup.py @@ -4,7 +4,9 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .royals import Royal +# noinspection PyUnresolvedReferences from .keygroup import Keygroup diff --git a/royalnet/database/tables/aliases.py b/royalnet/database/tables/aliases.py index d250596f..16a42fe5 100644 --- a/royalnet/database/tables/aliases.py +++ b/royalnet/database/tables/aliases.py @@ -4,6 +4,7 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .royals import Royal diff --git a/royalnet/database/tables/diario.py b/royalnet/database/tables/diario.py index 12067595..ead9b6e6 100644 --- a/royalnet/database/tables/diario.py +++ b/royalnet/database/tables/diario.py @@ -8,6 +8,7 @@ from sqlalchemy import Column, \ String from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .royals import Royal diff --git a/royalnet/database/tables/discord.py b/royalnet/database/tables/discord.py index b259ea05..563d1474 100644 --- a/royalnet/database/tables/discord.py +++ b/royalnet/database/tables/discord.py @@ -5,6 +5,7 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .royals import Royal diff --git a/royalnet/database/tables/keyvalue.py b/royalnet/database/tables/keyvalue.py index 4d4859ae..f93ee977 100644 --- a/royalnet/database/tables/keyvalue.py +++ b/royalnet/database/tables/keyvalue.py @@ -3,6 +3,7 @@ from sqlalchemy import Column, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .keygroup import Keygroup diff --git a/royalnet/database/tables/telegram.py b/royalnet/database/tables/telegram.py index 5a8ba600..f5725c41 100644 --- a/royalnet/database/tables/telegram.py +++ b/royalnet/database/tables/telegram.py @@ -2,10 +2,10 @@ from sqlalchemy import Column, \ Integer, \ String, \ BigInteger, \ - LargeBinary, \ ForeignKey from sqlalchemy.orm import relationship from sqlalchemy.ext.declarative import declared_attr +# noinspection PyUnresolvedReferences from .royals import Royal diff --git a/royalnet/network/messages.py b/royalnet/network/messages.py index fbc2747a..81dc85e5 100644 --- a/royalnet/network/messages.py +++ b/royalnet/network/messages.py @@ -1,4 +1,3 @@ -import traceback from ..error import RoyalnetError diff --git a/royalnet/network/royalnetconfig.py b/royalnet/network/royalnetconfig.py index 8c0e355c..5e35695a 100644 --- a/royalnet/network/royalnetconfig.py +++ b/royalnet/network/royalnetconfig.py @@ -1,6 +1,3 @@ -import typing - - class RoyalnetConfig: def __init__(self, master_uri: str, diff --git a/royalnet/network/royalnetlink.py b/royalnet/network/royalnetlink.py index 2be3d189..ff4783a0 100644 --- a/royalnet/network/royalnetlink.py +++ b/royalnet/network/royalnetlink.py @@ -146,7 +146,6 @@ class RoyalnetLink: assert isinstance(response, Message) except Exception as exc: response = RequestError(exc=exc) - return response_package: Package = package.reply(response) await self.send(response_package) log.debug(f"Replied to request {response_package.source_conv_id}: {response_package}") diff --git a/royalnet/utils/call.py b/royalnet/utils/call.py index d5c7db91..bf470925 100644 --- a/royalnet/utils/call.py +++ b/royalnet/utils/call.py @@ -1,6 +1,5 @@ import typing import asyncio -import logging from ..network.messages import Message from .command import Command from .commandargs import CommandArgs diff --git a/royalnet/utils/command.py b/royalnet/utils/command.py index 03584ce5..5c88f33c 100644 --- a/royalnet/utils/command.py +++ b/royalnet/utils/command.py @@ -1,6 +1,5 @@ import typing from ..error import UnsupportedError -from ..network import Message if typing.TYPE_CHECKING: from .call import Call from ..utils import NetworkHandler diff --git a/royalnet/utils/networkhandler.py b/royalnet/utils/networkhandler.py index 73114bcd..5d13fbdd 100644 --- a/royalnet/utils/networkhandler.py +++ b/royalnet/utils/networkhandler.py @@ -1,7 +1,3 @@ -from ..network import Message -from ..error import UnsupportedError - - class NetworkHandler: """The NetworkHandler functions are called when a specific Message type is received."""