Skip to content

Commit 48e8c3d

Browse files
committed
update latest ruff ruling
1 parent c1c7231 commit 48e8c3d

File tree

2 files changed

+19
-23
lines changed

2 files changed

+19
-23
lines changed

core/context.py

+4-7
Original file line numberDiff line numberDiff line change
@@ -37,25 +37,22 @@ def replied_message(self) -> discord.Message:
3737
return self.message
3838

3939
def author_is_mod(self) -> bool:
40-
member: discord.Member
40+
member: discord.Member | None
4141

4242
if self.guild is None: # dms
4343
guild = self.bot.get_guild(GUILD_ID)
4444

4545
if not guild:
4646
return False
4747

48-
_member = guild.get_member(self.author.id)
49-
if _member is not None:
50-
member = _member
51-
52-
else:
48+
member = guild.get_member(self.author.id)
49+
if member is None:
5350
return False
5451

5552
else:
5653
member = self.author # pyright: ignore[reportAssignmentType] # type lie for a shortcut
5754

58-
roles = member._roles # pyright: ignore[reportPrivateUsage] # we know this won't change for a while
55+
roles = member._roles # pyright: ignore[reportPrivateUsage,reportOptionalMemberAccess] # we know this won't change for a while
5956
return roles.has(Roles.ADMIN) or roles.has(Roles.MODERATOR)
6057

6158

modules/github.py

+15-16
Original file line numberDiff line numberDiff line change
@@ -118,29 +118,29 @@ async def format_highlight_block(self, url: str, line_adjustment: int = 10) -> d
118118
return None
119119

120120
bound_adj = line_adjustment # adjustment for upper and lower bound display.
121-
_min_boundary = highlighted_line - 1 - bound_adj if bulk is False else line_start - 1
122-
_max_boundary = highlighted_line - 1 + bound_adj if bulk is False else line_end - 1
121+
min_boundary = highlighted_line - 1 - bound_adj if bulk is False else line_start - 1
122+
max_boundary = highlighted_line - 1 + bound_adj if bulk is False else line_end - 1
123123

124124
# is our minimum greater than our maximum?
125-
if _min_boundary > _max_boundary:
125+
if min_boundary > max_boundary:
126126
# re-arrange the variables so we get the proper min - max scale
127-
_min = _min_boundary
128-
_max = _max_boundary
127+
min_ = min_boundary
128+
max_ = max_boundary
129129

130-
_min_boundary = _max
131-
_max_boundary = _min
130+
min_boundary = max_
131+
max_boundary = min_
132132

133133
# get the file extension to format nicely
134134
file = match["file"]
135135
extension = file.rsplit(".")[-1]
136136

137137
msg = f"```{extension}\n"
138-
key = _min_boundary
138+
key = min_boundary
139139

140-
max_digit = len(str(_max_boundary))
140+
max_digit = len(str(max_boundary))
141141

142142
# loop through all our lines
143-
while key <= _max_boundary:
143+
while key <= max_boundary:
144144
curr_line_no: str = str(key + 1)
145145
spaced_line_no = f"%{max_digit}d" % int(curr_line_no)
146146

@@ -164,9 +164,8 @@ async def format_highlight_block(self, url: str, line_adjustment: int = 10) -> d
164164

165165
return {
166166
"path": file_path,
167-
"min": (_min_boundary if _min_boundary > 0 else highlighted_line - 1)
168-
+ 1, # Do not display negative numbers if <0
169-
"max": _max_boundary + 1,
167+
"min": (min_boundary if min_boundary > 0 else highlighted_line - 1) + 1, # Do not display negative numbers if <0
168+
"max": max_boundary + 1,
170169
"msg": msg,
171170
}
172171

@@ -226,8 +225,8 @@ async def on_message(self, message: discord.Message) -> None:
226225
await message.add_reaction(self.code_highlight_emoji)
227226

228227
path = code_segment["path"]
229-
_min = code_segment["min"]
230-
_max = code_segment["max"]
228+
min_ = code_segment["min"]
229+
max_ = code_segment["max"]
231230
code_fmt = code_segment["msg"]
232231
assert isinstance(code_fmt, str)
233232

@@ -251,7 +250,7 @@ def check(reaction: discord.Reaction, user: discord.User) -> bool:
251250
await message.channel.send("You've selected too many lines for me to display!")
252251
return
253252

254-
msg: str = f"Showing lines `{_min}-{_max}` in: `{path}`\n{code_fmt}"
253+
msg: str = f"Showing lines `{min_}-{max_}` in: `{path}`\n{code_fmt}"
255254
await message.channel.send(msg, suppress_embeds=True)
256255

257256
except TimeoutError:

0 commit comments

Comments
 (0)