diff --git a/bot/bot.py b/bot/bot.py index 19287a3..6795c51 100755 --- a/bot/bot.py +++ b/bot/bot.py @@ -56,7 +56,7 @@ async def connect(cls) -> bool: token.parse_friends(), token.update_stats(), token.parse_country(), # we don't needed ip, we are bots - ] + ], ) u_panel = PacketBuilder.UserPresence(token) @@ -139,7 +139,7 @@ async def proceed_command(cls, message: "Message") -> bool: message.body = message.body.strip() cmd, func_command = None, None - for (k, func) in cls.commands.items(): + for k, func in cls.commands.items(): if message.body.startswith(k): cmd, func_command = k, func break diff --git a/bot/commands/multiplayer.py b/bot/commands/multiplayer.py index 12519fc..3b7f9ca 100755 --- a/bot/commands/multiplayer.py +++ b/bot/commands/multiplayer.py @@ -417,7 +417,7 @@ async def mp_set(args: List[str], player: "Player", __): MatchTeamTypes(match_team_type) == MatchTeamTypes.TagTeamVs or match_team_type == MatchTeamTypes.TeamVs ): - for (i, slot) in enumerate(player.match.slots): + for i, slot in enumerate(player.match.slots): if slot.team == SlotTeams.Neutral: slot.team = SlotTeams.Red if i % 2 == 1 else SlotTeams.Blue else: diff --git a/bot/commands/tillerino.py b/bot/commands/tillerino.py index 4757d42..12dfdce 100755 --- a/bot/commands/tillerino.py +++ b/bot/commands/tillerino.py @@ -46,6 +46,7 @@ "RX": Mods.Relax, } + # pylint: disable=consider-using-f-string async def get_pp_message( token: "Player", diff --git a/handlers/decorators/event.py b/handlers/decorators/event.py index 882b811..a0d9613 100755 --- a/handlers/decorators/event.py +++ b/handlers/decorators/event.py @@ -4,7 +4,6 @@ class OsuEvent: - handlers = {} def __new__(cls): diff --git a/handlers/decorators/http.py b/handlers/decorators/http.py index 0bf72a4..b8c286a 100755 --- a/handlers/decorators/http.py +++ b/handlers/decorators/http.py @@ -1,5 +1,4 @@ class HttpEvent: - handlers = {} def __new__(cls): diff --git a/handlers/eventhandlers/41-update-match.py b/handlers/eventhandlers/41-update-match.py index 1d255e5..fb4e67b 100755 --- a/handlers/eventhandlers/41-update-match.py +++ b/handlers/eventhandlers/41-update-match.py @@ -40,7 +40,7 @@ async def update_match(data: bytes, token: "Player"): new_match["team_type"] == MatchTeamTypes.TagTeamVs or new_match["team_type"] == MatchTeamTypes.TeamVs ): - for (i, slot) in enumerate(match.slots): + for i, slot in enumerate(match.slots): if slot.team == SlotTeams.Neutral: slot.team = SlotTeams.Red if i % 2 == 1 else SlotTeams.Blue else: diff --git a/handlers/eventhandlers/47-match-score-update.py b/handlers/eventhandlers/47-match-score-update.py index 0f4a1e7..80c57ff 100755 --- a/handlers/eventhandlers/47-match-score-update.py +++ b/handlers/eventhandlers/47-match-score-update.py @@ -19,7 +19,7 @@ async def match_score_update(packet_data: bytes, token: "Player"): match = token.match slotInd = -1 - for (ind, slot) in enumerate(match.slots): + for ind, slot in enumerate(match.slots): if slot.token == token: slotInd = ind break diff --git a/handlers/eventhandlers/56-match-failed.py b/handlers/eventhandlers/56-match-failed.py index 0dd3e08..2277d68 100755 --- a/handlers/eventhandlers/56-match-failed.py +++ b/handlers/eventhandlers/56-match-failed.py @@ -17,7 +17,7 @@ async def player_failed(_, token: "Player"): match = token.match slot_ind = -1 - for (ind, slot) in enumerate(match.slots): + for ind, slot in enumerate(match.slots): if slot.token == token: slot_ind = ind break diff --git a/handlers/httphandlers/main_handler.py b/handlers/httphandlers/main_handler.py index 743b261..b05b96a 100755 --- a/handlers/httphandlers/main_handler.py +++ b/handlers/httphandlers/main_handler.py @@ -53,7 +53,7 @@ async def main_handler(request: Request): # packets recieve with memoryview(await request.body()) as packets: raw_bytes = KurisoPacketReader(packets) - response = bytes() + response = b'' while not raw_bytes.EOF(): packet_id = raw_bytes.read_u_int_16() _ = raw_bytes.read_int_8() # empty byte @@ -234,7 +234,7 @@ async def main_handler(request: Request): player.parse_friends(), player.update_stats(), player.parse_country(request.client.host), - ] + ], ) if "ppy.sh" in request.url.netloc and not (player.is_admin or player.is_tournament_stuff): @@ -316,10 +316,10 @@ async def main_handler(request: Request): Context.channels["#osu"].join_channel(player), Context.channels["#announce"].join_channel(player), Context.channels["#english"].join_channel(player), - ] + ], ) - for (_, chan) in Context.channels.items(): + for _, chan in Context.channels.items(): if not chan.temp_channel and chan.can_read: start_bytes += PacketBuilder.ChannelAvailable(chan) diff --git a/index.py b/index.py index c1c057e..ed4a271 100755 --- a/index.py +++ b/index.py @@ -73,7 +73,7 @@ async def main(): redis_values["password"] = Config.config["redis"]["password"] redis_pool = await aioredis.from_url( - f"redis://{Config.config['redis']['host']}", **redis_values + f"redis://{Config.config['redis']['host']}", **redis_values, ) Context.redis = redis_pool diff --git a/irc/server.py b/irc/server.py index bf81e5b..83e897e 100644 --- a/irc/server.py +++ b/irc/server.py @@ -23,6 +23,7 @@ NAME = "kuriso!irc" WHITE_SPACE = re.compile(r"\r?\n") + # Custom Bancho IRC exception. class BanchoIRCException(Exception): """Custom expection.""" @@ -146,7 +147,7 @@ async def login(self, irc_token: str = ""): player.parse_friends(), player.update_stats(), player.parse_country(), - ] + ], ) logger.klog(f"<{start_data['username']}> logged in, through irc!chat") diff --git a/loops.py b/loops.py index d41b5b3..d8626da 100755 --- a/loops.py +++ b/loops.py @@ -14,12 +14,12 @@ async def clean_timeouts(): """ tasks = [] - for (_, user) in Context.players.store_by_token.items(): + for _, user in Context.players.store_by_token.items(): if user.is_bot: continue # ignore bot if hasattr(user, "additional_clients"): - for (_, sub_user) in user.additional_clients.items(): + for _, sub_user in user.additional_clients.items(): if int(time.time()) - sub_user.last_packet_unix > LAST_PACKET_TIMEOUT: logger.slog(f"[Player/{user.name}/subclient] was kicked during timeout") # simulate logout packet diff --git a/objects/BanchoObjects.py b/objects/BanchoObjects.py index c7c0594..3bdb5f1 100755 --- a/objects/BanchoObjects.py +++ b/objects/BanchoObjects.py @@ -2,7 +2,6 @@ class Message: - __slots__ = ("sender", "to", "body", "client_id", "when") def __init__(self, sender: str = "", to: str = "", body: str = "", client_id: int = 0): diff --git a/objects/BotPlayer.py b/objects/BotPlayer.py index f912a33..0582350 100755 --- a/objects/BotPlayer.py +++ b/objects/BotPlayer.py @@ -103,7 +103,7 @@ async def update_stats(self, selected_mode: GameModes = None) -> bool: async def logout(self) -> None: # leave channels - for (_, chan) in Context.channels.items(): + for _, chan in Context.channels.items(): if self.id in chan.users: await chan.leave_channel(self) diff --git a/objects/IRCPlayer.py b/objects/IRCPlayer.py index a0384ee..0b703cf 100644 --- a/objects/IRCPlayer.py +++ b/objects/IRCPlayer.py @@ -85,7 +85,7 @@ async def logout(self) -> None: await userHelper.deleteBanchoSession(self.id, self.ip) # leave channels - for (_, chan) in Context.channels.items(): + for _, chan in Context.channels.items(): if self.id in chan.users: await chan.leave_channel(self) diff --git a/objects/Player.py b/objects/Player.py index e2cc5bd..4a144ba 100755 --- a/objects/Player.py +++ b/objects/Player.py @@ -126,7 +126,7 @@ def __init__( self._match: Optional["Match"] = None - self.queue = bytes() # main thing + self.queue = b'' # main thing self.login_time = int(time.time()) self.last_packet_unix = int(time.time()) @@ -299,7 +299,7 @@ async def update_stats(self, selected_mode: GameModes = None) -> bool: ) self.stats[gm].update( - **{**task, **{"leaderboard_rank": int(position) + 1 if position else 0}} + **{**task, **{"leaderboard_rank": int(position) + 1 if position else 0}}, ) async def logout(self) -> None: @@ -319,7 +319,7 @@ async def logout(self) -> None: await self.spectating.remove_spectator(self) # leave channels - for (_, chan) in Context.channels.items(): + for _, chan in Context.channels.items(): if self.id in chan.users: await chan.leave_channel(self) @@ -534,7 +534,7 @@ def enqueue(self, b: bytes) -> None: def dequeue(self) -> Optional[bytes]: if self.queue: data = self.queue - self.queue = bytes() + self.queue = b'' return data return b"" diff --git a/objects/TokenStorage.py b/objects/TokenStorage.py index 8be3e05..9cf524e 100755 --- a/objects/TokenStorage.py +++ b/objects/TokenStorage.py @@ -39,7 +39,7 @@ def get_token( if token: if not self.store_by_token.get(token, None): # we can't find token, but probably it's additional client?! - for (_, user) in self.store_by_token.items(): + for _, user in self.store_by_token.items(): if hasattr(user, "additional_clients"): if token in user.additional_clients: return user.additional_clients.get(token, None) @@ -55,7 +55,7 @@ def get_token( def delete_token(self, token: "Player") -> bool: if token.is_tourneymode: - for (_, user) in self.store_by_token.items(): + for _, user in self.store_by_token.items(): if hasattr(user, "additional_clients"): if token.token in user.additional_clients: user.additional_clients.pop(token.token) @@ -84,7 +84,7 @@ def get_all_tokens( ] # just return all player instances additional_tokens = [] if not ignore_tournament_clients: - for (_, user) in self.store_by_token.items(): + for _, user in self.store_by_token.items(): if hasattr(user, "additional_clients"): additional_tokens.extend( [token for (_, token) in user.additional_clients.items()], diff --git a/packets/Builder/index.py b/packets/Builder/index.py index d82a59a..f8e956e 100755 --- a/packets/Builder/index.py +++ b/packets/Builder/index.py @@ -166,7 +166,7 @@ def write_mp_match(self, arguments: List[Union["Match", bool]]) -> bool: # 2 - (data, osuType) @staticmethod def CreateBanchoPacket( - pid: Union[int, OsuPacketID], *args: Union[Tuple[Any, int]] + pid: Union[int, OsuPacketID], *args: Union[Tuple[Any, int]], ) -> bytes: # writing packet writer = KurisoPacketWriter() @@ -206,7 +206,6 @@ def CreateBanchoPacket( class PacketBuilder: - # server packet: 5 @staticmethod def UserID(user_id: int) -> bytes: diff --git a/registrator.py b/registrator.py index a154172..56309bd 100755 --- a/registrator.py +++ b/registrator.py @@ -14,7 +14,7 @@ def load_handlers(app: Starlette): logger.wlog("[Handlers/Events] Loading handlers & events...") paths_to_import = {"handlers": ["httphandlers", "eventhandlers"]} - for (k, v) in paths_to_import.items(): + for k, v in paths_to_import.items(): sys.path.insert(0, k) for deep_path in v: sys.path.insert(0, f"{k}/{deep_path}") @@ -27,7 +27,7 @@ def load_handlers(app: Starlette): __import__(os.path.splitext(file)[0], None, None, [""]) handlers = [] - for (path, path_describe) in HttpEvent.handlers.items(): + for path, path_describe in HttpEvent.handlers.items(): logger.slog(f"[Handlers/Events] {path} registered!") handlers.append( Route(