1
Fork 0
mirror of https://github.com/RYGhub/royalnet.git synced 2024-11-23 19:44:20 +00:00

Fix a lot of warnings

This commit is contained in:
Steffo 2019-04-20 12:45:54 +02:00
parent ad8a0016bc
commit 22d30b89f2
20 changed files with 21 additions and 23 deletions

View file

@ -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__)

View file

@ -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__)

View file

@ -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!")

View file

@ -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].")

View file

@ -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:

View file

@ -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..")

View file

@ -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] = []

View file

@ -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()

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -1,4 +1,3 @@
import traceback
from ..error import RoyalnetError

View file

@ -1,6 +1,3 @@
import typing
class RoyalnetConfig:
def __init__(self,
master_uri: str,

View file

@ -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}")

View file

@ -1,6 +1,5 @@
import typing
import asyncio
import logging
from ..network.messages import Message
from .command import Command
from .commandargs import CommandArgs

View file

@ -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

View file

@ -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."""