Skip to content

Commit

Permalink
fix some errors/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
RuslanUC committed Mar 12, 2024
1 parent dc5a55d commit 179c46a
Show file tree
Hide file tree
Showing 16 changed files with 25 additions and 16 deletions.
1 change: 1 addition & 0 deletions yepcord/asgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
from quart_schema import RequestSchemaValidationError, QuartSchema
import yepcord.rest_api.main as rest_api
import yepcord.gateway.main as gateway
import yepcord.voice_gateway.main as voice_gateway
import yepcord.cdn.main as cdn
import yepcord.remote_auth.main as remote_auth
from yepcord.rest_api.routes import auth, connections
Expand Down
2 changes: 1 addition & 1 deletion yepcord/cdn/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ async def get_sticker(query_args: CdnImageSizeQuery, sticker_id: int, format_: s
break
else:
sticker = await getStorage().getSticker(sticker_id, query_args.size, format_,
sticker.format in (StickerFormat.APNG, StickerFormat.GIF))
sticker.format in (StickerFormat.APNG, StickerFormat.GIF))
if not sticker:
return b'', 404
return sticker, 200, {"Content-Type": f"image/{format_}"}
Expand Down
2 changes: 2 additions & 0 deletions yepcord/gateway/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,6 +1054,8 @@ async def json(self) -> dict:
"token_data": None,
}
}


class VoiceStateUpdate(DispatchEvent):
NAME = "VOICE_STATE_UPDATE"

Expand Down
2 changes: 1 addition & 1 deletion yepcord/gateway/gateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import warnings
from json import dumps as jdumps
from typing import Optional, Union
from typing import Union

from quart import Websocket
from redis.asyncio import Redis
Expand Down
1 change: 1 addition & 0 deletions yepcord/rest_api/models/channels.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,7 @@ def validate_title(cls, value: str):
raise EmbedErr(makeEmbedError(27, f"title", {"length": "256"}))
return value

# noinspection PyUnusedLocal
@field_validator("type")
def validate_type(cls, value: Optional[str]):
return "rich"
Expand Down
4 changes: 2 additions & 2 deletions yepcord/rest_api/models/oauth2.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,12 @@ class AppAuthorizeGetQs(BaseModel):
client_id: Optional[int] = None
scope: Optional[str] = None

def __init__(self, *args, **kwargs):
def __init__(self, **kwargs):
if "client_id" not in kwargs or not kwargs.get("client_id", "").strip():
raise InvalidDataErr(400, Errors.make(50035, {"client_id": {
"code": "BASE_TYPE_REQUIRED", "message": "This field is required"
}}))
super().__init__(*args, **kwargs)
super().__init__(**kwargs)


class AppAuthorizePostQs(BaseModel):
Expand Down
5 changes: 5 additions & 0 deletions yepcord/rest_api/routes/other.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ async def api_outboundpromotions():
return []


# noinspection PyUnusedLocal
@other.get("/api/v9/users/@me/applications/<aid>/entitlements")
async def api_users_me_applications_id_entitlements(aid):
return []
Expand Down Expand Up @@ -187,6 +188,7 @@ async def api_users_me_settingsproto_3():
return {"settings": ""}


# noinspection PyUnusedLocal
@other.route("/api/v9/users/@me/settings-proto/<int:t>", methods=["GET", "PATCH"])
async def api_users_me_settingsproto_type(t):
raise InvalidDataErr(400, Errors.make(50035, {"type": {
Expand All @@ -196,16 +198,19 @@ async def api_users_me_settingsproto_type(t):
}}))


# noinspection PyUnusedLocal
@other.get("/api/v9/applications/<int:app_id>/skus")
async def application_skus(app_id: int):
return []


# noinspection PyUnusedLocal
@other.get("/api/v9/applications/<int:app_id>/subscription-group-listings")
async def application_sub_group_list(app_id: int):
return {"items": []}


# noinspection PyUnusedLocal
@other.get("/api/v9/applications/<int:app_id>/listings")
async def application_listings(app_id: int):
return []
Expand Down
2 changes: 1 addition & 1 deletion yepcord/rest_api/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
import yepcord.yepcord.models as models
from ..yepcord.classes.captcha import Captcha
from ..yepcord.config import Config
from ..yepcord.ctx import Ctx, getCore, getCDNStorage
from ..yepcord.ctx import getCore, getCDNStorage
from ..yepcord.enums import MessageType
from ..yepcord.errors import Errors, InvalidDataErr
from ..yepcord.models import Session, User, Channel, Attachment, Authorization, Bot, Webhook, Message
Expand Down
2 changes: 1 addition & 1 deletion yepcord/rest_api/y_blueprint.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from fast_depends import inject
from flask.sansio.scaffold import T_route, setupmethod
from quart import Blueprint, g
from quart_schema import validate_request, DataSource, validate_querystring
from quart_schema import validate_request, validate_querystring

validate_funcs = {"body": validate_request, "qs": validate_querystring}

Expand Down
4 changes: 2 additions & 2 deletions yepcord/yepcord/classes/gifs.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ class Gifs(Singleton):
def __init__(self, key: str = None, keep_searches: int = 100):
self._key = key
self._categories = []
self._last_searches = []
self._last_suggestions = []
self._last_searches: list[GifSearchResult] = []
self._last_suggestions: list[GifSuggestion] = []
self._last_update = 0
self._keep_searches = keep_searches

Expand Down
5 changes: 3 additions & 2 deletions yepcord/yepcord/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,8 @@ async def getChannelMessagesCount(self, channel: Channel) -> int:

async def getPrivateChannels(self, user: User, with_hidden: bool = False) -> list[Channel]:
channels = await Channel.filter(recipients__id=user.id).select_related("owner").all()
channels = [channel for channel in channels if not await self.isDmChannelHidden(user, channel)]
if not with_hidden:
channels = [channel for channel in channels if not await self.isDmChannelHidden(user, channel)]
return [await self.setLastMessageIdForChannel(channel) for channel in channels]

async def getChannelMessages(self, channel: Channel, limit: int, before: int = 0, after: int = 0) -> list[Message]:
Expand Down Expand Up @@ -775,7 +776,7 @@ async def getGuildMembersGw(self, guild: Guild, query: str, limit: int, user_ids
# noinspection PyUnresolvedReferences
return await GuildMember.filter(
Q(guild=guild) &
(Q(nick__startswith=query) | Q(user__userdatas__username__istartswith=query)) #&
(Q(nick__startswith=query) | Q(user__userdatas__username__istartswith=query)) #&
#((GuildMember.user.id in user_ids) if user_ids else (GuildMember.user.id not in [0]))
).select_related("user").limit(limit).all()

Expand Down
2 changes: 1 addition & 1 deletion yepcord/yepcord/gateway_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ async def dispatchSub(self, user_ids: list[int], guild_id: int = None, role_id:
"role_id": role_id,
})

async def dispatchUnsub(self, user_ids: list[int], guild_id: int = None, role_id: int = None, delete = False) -> None:
async def dispatchUnsub(self, user_ids: list[int], guild_id: int = None, role_id: int = None, delete=False) -> None:
await self.dispatchSys("unsub", {
"user_ids": user_ids,
"guild_id": guild_id,
Expand Down
2 changes: 1 addition & 1 deletion yepcord/yepcord/models/audit_log_entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ async def role_delete(user: models.User, role: models.Role) -> AuditLogEntry:
@staticmethod
async def bot_add(user: models.User, guild: models.Guild, bot: models.User) -> AuditLogEntry:
return await AuditLogEntry.create(id=Snowflake.makeId(), guild=guild, user=user, target_id=bot.id,
action_type=AuditLogEntryType.BOT_ADD)
action_type=AuditLogEntryType.BOT_ADD)

@staticmethod
async def integration_create(user: models.User, guild: models.Guild, bot: models.User) -> AuditLogEntry:
Expand Down
2 changes: 1 addition & 1 deletion yepcord/yepcord/models/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async def ds_json(self, user_id: int=None, with_ids: bool=True) -> dict:
userdata = await recipient.data
recipients.append(userdata.ds_json)

base_data = {
base_data: dict = {
"id": str(self.id),
"type": self.type,
}
Expand Down
1 change: 0 additions & 1 deletion yepcord/yepcord/models/userdata.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
from datetime import date, timedelta
from typing import Optional

from quart import g
from tortoise import fields
from tortoise.validators import MinValueValidator, MaxValueValidator

Expand Down
4 changes: 2 additions & 2 deletions yepcord/yepcord/mq_broker.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ def _handle(func):

def getBroker() -> Union[RabbitBroker, RedisBroker, KafkaBroker, NatsBroker, WsBroker]:
broker_type = Config.MESSAGE_BROKER["type"].lower()
assert broker_type in ("rabbitmq", "redis", "sqs", "kafka", "nats", "ws",), \
"MESSAGE_BROKER.type must be one of ('rabbitmq', 'redis', 'sqs', 'kafka', 'nats', 'ws')"
assert broker_type in ("rabbitmq", "redis", "kafka", "nats", "ws",), \
"MESSAGE_BROKER.type must be one of ('rabbitmq', 'redis', 'kafka', 'nats', 'ws')"

if broker_type == "ws":
warnings.warn("'ws' message broker type is used. This message broker type should not be used in production!")
Expand Down

0 comments on commit 179c46a

Please sign in to comment.