Skip to content

Commit 1206d86

Browse files
committed
Code updates for new linter version
1 parent ae32c4d commit 1206d86

File tree

3 files changed

+43
-47
lines changed

3 files changed

+43
-47
lines changed

bot/exts/advent_of_code/_helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ async def countdown_status(bot: SirRobin) -> None:
477477
while arrow.now(EST) < end:
478478
_, time_left = time_left_to_est_midnight()
479479

480-
aligned_seconds = int(math.ceil(time_left.seconds / COUNTDOWN_STEP)) * COUNTDOWN_STEP
480+
aligned_seconds = math.ceil(time_left.seconds / COUNTDOWN_STEP) * COUNTDOWN_STEP
481481
hours, minutes = aligned_seconds // 3600, aligned_seconds // 60 % 60
482482

483483
if aligned_seconds == 0:

bot/exts/smart_eval/_cog.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ async def improve_gpu_name(self, hardware_name: str) -> str:
6464
async def donations(self, ctx: commands.Context) -> None:
6565
"""Display the number of donations recieved so far."""
6666
total_donations = await self.total_donations()
67-
response_time, intelligence_level = await self.get_gpu_capabilities()
67+
_response_time, intelligence_level = await self.get_gpu_capabilities()
6868
msg = (
6969
f"Currently, I have received {total_donations} GPU donations, "
7070
f"and am at intelligence level {intelligence_level}! "
@@ -138,7 +138,7 @@ async def donate(self, ctx: commands.Context, *, hardware: str | None = None) ->
138138
@commands.max_concurrency(1, commands.BucketType.user)
139139
async def smart_eval(self, ctx: commands.Context, *, code: str) -> None:
140140
"""Evaluate your Python code with PyDis's newest chatbot."""
141-
response_time, intelligence_level = await self.get_gpu_capabilities()
141+
response_time, _intelligence_level = await self.get_gpu_capabilities()
142142

143143
if match := FORMATTED_CODE_REGEX.match(code):
144144
code = match.group("code")

tests/helpers.py

Lines changed: 40 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import annotations
2-
31
import collections
42
import itertools
53
import logging
@@ -143,6 +141,46 @@ def _get_child_mock(self, **kw):
143141
}
144142
guild_instance = discord.Guild(data=guild_data, state=unittest.mock.MagicMock())
145143

144+
# Create a Role instance to get a realistic Mock of `discord.Role`
145+
role_data = {"name": "role", "id": 1}
146+
role_instance = discord.Role(guild=guild_instance, state=unittest.mock.MagicMock(), data=role_data)
147+
148+
class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin):
149+
"""
150+
A Mock subclass to mock `discord.Role` objects.
151+
152+
Instances of this class will follow the specifications of `discord.Role` instances. For more
153+
information, see the `MockGuild` docstring.
154+
"""
155+
spec_set = role_instance
156+
157+
def __init__(self, **kwargs) -> None:
158+
default_kwargs = {
159+
"id": next(self.discord_id),
160+
"name": "role",
161+
"position": 1,
162+
"colour": discord.Colour(0xdeadbf),
163+
"permissions": discord.Permissions(),
164+
}
165+
super().__init__(**collections.ChainMap(kwargs, default_kwargs))
166+
167+
if isinstance(self.colour, int):
168+
self.colour = discord.Colour(self.colour)
169+
170+
if isinstance(self.permissions, int):
171+
self.permissions = discord.Permissions(self.permissions)
172+
173+
if "mention" not in kwargs:
174+
self.mention = f"&{self.name}"
175+
176+
def __lt__(self, other):
177+
"""Simplified position-based comparisons similar to those of `discord.Role`."""
178+
return self.position < other.position
179+
180+
def __ge__(self, other):
181+
"""Simplified position-based comparisons similar to those of `discord.Role`."""
182+
return self.position >= other.position
183+
146184

147185
class MockGuild(CustomMockMixin, unittest.mock.Mock, HashableMixin):
148186
"""
@@ -188,48 +226,6 @@ def roles(self) -> list[MockRole]:
188226
return [MockRole(name="@everyone", position=1, id=0)]
189227

190228

191-
# Create a Role instance to get a realistic Mock of `discord.Role`
192-
role_data = {"name": "role", "id": 1}
193-
role_instance = discord.Role(guild=guild_instance, state=unittest.mock.MagicMock(), data=role_data)
194-
195-
196-
class MockRole(CustomMockMixin, unittest.mock.Mock, ColourMixin, HashableMixin):
197-
"""
198-
A Mock subclass to mock `discord.Role` objects.
199-
200-
Instances of this class will follow the specifications of `discord.Role` instances. For more
201-
information, see the `MockGuild` docstring.
202-
"""
203-
spec_set = role_instance
204-
205-
def __init__(self, **kwargs) -> None:
206-
default_kwargs = {
207-
"id": next(self.discord_id),
208-
"name": "role",
209-
"position": 1,
210-
"colour": discord.Colour(0xdeadbf),
211-
"permissions": discord.Permissions(),
212-
}
213-
super().__init__(**collections.ChainMap(kwargs, default_kwargs))
214-
215-
if isinstance(self.colour, int):
216-
self.colour = discord.Colour(self.colour)
217-
218-
if isinstance(self.permissions, int):
219-
self.permissions = discord.Permissions(self.permissions)
220-
221-
if "mention" not in kwargs:
222-
self.mention = f"&{self.name}"
223-
224-
def __lt__(self, other):
225-
"""Simplified position-based comparisons similar to those of `discord.Role`."""
226-
return self.position < other.position
227-
228-
def __ge__(self, other):
229-
"""Simplified position-based comparisons similar to those of `discord.Role`."""
230-
return self.position >= other.position
231-
232-
233229
# Create a Member instance to get a realistic Mock of `discord.Member`
234230
member_data = {"user": "lemon", "roles": [1], "flags": 2}
235231
state_mock = unittest.mock.MagicMock()

0 commit comments

Comments
 (0)