Skip to content

Commit a57d882

Browse files
committed
Address PLW2901 - redefined-loop-name
Newer version of ruff warns about this (optional) pylint check in three sites. Address this by replacing a few constructs where we were splitting on comma and stripping, by using a generator instead.
1 parent 91d26ce commit a57d882

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

ircstream.py

+3-7
Original file line numberDiff line numberDiff line change
@@ -570,9 +570,7 @@ async def handle_join(self, params: list[str]) -> None:
570570
except IndexError:
571571
raise IRCError(ERR.NEEDMOREPARAMS, ["JOIN", "Not enough parameters"]) from None
572572

573-
for channel in channels.split(","):
574-
channel = channel.strip()
575-
573+
for channel in (i.strip() for i in channels.split(",")):
576574
# is this a valid channel name?
577575
if not re.fullmatch(r"#([\w\d_\.-])+", channel) or len(channel) > 50:
578576
await self.msg(ERR.NOSUCHCHANNEL, [channel, "No such channel"])
@@ -649,8 +647,7 @@ async def handle_privmsg(self, params: list[str]) -> None:
649647
except ValueError:
650648
raise IRCError(ERR.NEEDMOREPARAMS, ["PRIVMSG", "Not enough parameters"]) from None
651649

652-
for target in targets.split(","):
653-
target = target.strip()
650+
for target in (i.strip() for i in targets.split(",")):
654651
if target.startswith("#"):
655652
await self.msg(ERR.CANNOTSENDTOCHAN, [target, "Cannot send to channel"])
656653
elif target == self.server.botname:
@@ -680,8 +677,7 @@ async def handle_part(self, params: list[str]) -> None:
680677
except IndexError:
681678
raise IRCError(ERR.NEEDMOREPARAMS, ["PART", "Not enough parameters"]) from None
682679

683-
for channel in channels.split(","):
684-
channel = channel.strip()
680+
for channel in (i.strip() for i in channels.split(",")):
685681
if channel in self.channels:
686682
self.channels.remove(channel) # remove from client's own channel list
687683
self.server.unsubscribe(channel, self) # unsubscribe from the server's (global) list

0 commit comments

Comments
 (0)