Skip to content

Commit 4ed7f3a

Browse files
committed
Update Pyright to v1.1.394
1 parent b5aef72 commit 4ed7f3a

30 files changed

+94
-81
lines changed

.github/workflows/lint.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
- name: Run Pyright
3939
uses: jakebailey/pyright-action@v1
4040
with:
41-
version: '1.1.351'
41+
version: '1.1.394'
4242
warnings: false
4343
no-comments: ${{ matrix.python-version != '3.x' }}
4444

discord/abc.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@
102102
GuildChannel as GuildChannelPayload,
103103
OverwriteType,
104104
)
105+
from .types.guild import (
106+
ChannelPositionUpdate,
107+
)
105108
from .types.snowflake import (
106109
SnowflakeList,
107110
)
@@ -1232,11 +1235,11 @@ async def move(self, **kwargs: Any) -> None:
12321235
raise ValueError('Could not resolve appropriate move position')
12331236

12341237
channels.insert(max((index + offset), 0), self)
1235-
payload = []
1238+
payload: List[ChannelPositionUpdate] = []
12361239
lock_permissions = kwargs.get('sync_permissions', False)
12371240
reason = kwargs.get('reason')
12381241
for index, channel in enumerate(channels):
1239-
d = {'id': channel.id, 'position': index}
1242+
d: ChannelPositionUpdate = {'id': channel.id, 'position': index}
12401243
if parent_id is not MISSING and channel.id == self.id:
12411244
d.update(parent_id=parent_id, lock_permissions=lock_permissions)
12421245
payload.append(d)

discord/activity.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ def to_dict(self) -> Dict[str, Any]:
273273
def start(self) -> Optional[datetime.datetime]:
274274
"""Optional[:class:`datetime.datetime`]: When the user started doing this activity in UTC, if applicable."""
275275
try:
276-
timestamp = self.timestamps['start'] / 1000
276+
timestamp = self.timestamps['start'] / 1000 # pyright: ignore[reportTypedDictNotRequiredAccess]
277277
except KeyError:
278278
return None
279279
else:
@@ -283,7 +283,7 @@ def start(self) -> Optional[datetime.datetime]:
283283
def end(self) -> Optional[datetime.datetime]:
284284
"""Optional[:class:`datetime.datetime`]: When the user will stop doing this activity in UTC, if applicable."""
285285
try:
286-
timestamp = self.timestamps['end'] / 1000
286+
timestamp = self.timestamps['end'] / 1000 # pyright: ignore[reportTypedDictNotRequiredAccess]
287287
except KeyError:
288288
return None
289289
else:
@@ -293,7 +293,7 @@ def end(self) -> Optional[datetime.datetime]:
293293
def large_image_url(self) -> Optional[str]:
294294
"""Optional[:class:`str`]: Returns a URL pointing to the large image asset of this activity, if applicable."""
295295
try:
296-
large_image = self.assets['large_image']
296+
large_image = self.assets['large_image'] # pyright: ignore[reportTypedDictNotRequiredAccess]
297297
except KeyError:
298298
return None
299299
else:
@@ -303,7 +303,7 @@ def large_image_url(self) -> Optional[str]:
303303
def small_image_url(self) -> Optional[str]:
304304
"""Optional[:class:`str`]: Returns a URL pointing to the small image asset of this activity, if applicable."""
305305
try:
306-
small_image = self.assets['small_image']
306+
small_image = self.assets['small_image'] # pyright: ignore[reportTypedDictNotRequiredAccess]
307307
except KeyError:
308308
return None
309309
else:
@@ -525,7 +525,7 @@ def twitch_name(self) -> Optional[str]:
525525
"""
526526

527527
try:
528-
name = self.assets['large_image']
528+
name = self.assets['large_image'] # pyright: ignore[reportTypedDictNotRequiredAccess]
529529
except KeyError:
530530
return None
531531
else:

discord/app_commands/commands.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -903,7 +903,7 @@ async def _invoke_autocomplete(self, interaction: Interaction, name: str, namesp
903903
predicates = getattr(param.autocomplete, '__discord_app_commands_checks__', [])
904904
if predicates:
905905
try:
906-
passed = await async_all(f(interaction) for f in predicates)
906+
passed = await async_all(f(interaction) for f in predicates) # type: ignore
907907
except Exception:
908908
passed = False
909909

@@ -1014,7 +1014,7 @@ async def _check_can_run(self, interaction: Interaction) -> bool:
10141014
if not predicates:
10151015
return True
10161016

1017-
return await async_all(f(interaction) for f in predicates)
1017+
return await async_all(f(interaction) for f in predicates) # type: ignore
10181018

10191019
def error(self, coro: Error[GroupT]) -> Error[GroupT]:
10201020
"""A decorator that registers a coroutine as a local error handler.
@@ -1308,7 +1308,7 @@ async def _check_can_run(self, interaction: Interaction) -> bool:
13081308
if not predicates:
13091309
return True
13101310

1311-
return await async_all(f(interaction) for f in predicates)
1311+
return await async_all(f(interaction) for f in predicates) # type: ignore
13121312

13131313
def _has_any_error_handlers(self) -> bool:
13141314
return self.on_error is not None
@@ -1842,7 +1842,7 @@ def error(self, coro: ErrorFunc) -> ErrorFunc:
18421842
if len(params) != 2:
18431843
raise TypeError('The error handler must have 2 parameters.')
18441844

1845-
self.on_error = coro
1845+
self.on_error = coro # type: ignore
18461846
return coro
18471847

18481848
async def interaction_check(self, interaction: Interaction, /) -> bool:

discord/app_commands/transformers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ def __call__(self) -> None:
235235
pass
236236

237237
def __or__(self, rhs: Any) -> Any:
238-
return Union[self, rhs] # type: ignore
238+
return Union[self, rhs]
239239

240240
@property
241241
def type(self) -> AppCommandOptionType:

discord/app_commands/tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ def error(self, coro: ErrorFunc[ClientT]) -> ErrorFunc[ClientT]:
859859
if len(params) != 2:
860860
raise TypeError('error handler must have 2 parameters')
861861

862-
self.on_error = coro
862+
self.on_error = coro # type: ignore
863863
return coro
864864

865865
def command(

discord/components.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ def __init__(self, data: ButtonComponentPayload, /) -> None:
196196
self.label: Optional[str] = data.get('label')
197197
self.emoji: Optional[PartialEmoji]
198198
try:
199-
self.emoji = PartialEmoji.from_dict(data['emoji'])
199+
self.emoji = PartialEmoji.from_dict(data['emoji']) # pyright: ignore[reportTypedDictNotRequiredAccess]
200200
except KeyError:
201201
self.emoji = None
202202

203203
try:
204-
self.sku_id: Optional[int] = int(data['sku_id'])
204+
self.sku_id: Optional[int] = int(data['sku_id']) # pyright: ignore[reportTypedDictNotRequiredAccess]
205205
except KeyError:
206206
self.sku_id = None
207207

@@ -415,7 +415,7 @@ def emoji(self, value: Optional[Union[str, Emoji, PartialEmoji]]) -> None:
415415
@classmethod
416416
def from_dict(cls, data: SelectOptionPayload) -> SelectOption:
417417
try:
418-
emoji = PartialEmoji.from_dict(data['emoji'])
418+
emoji = PartialEmoji.from_dict(data['emoji']) # pyright: ignore[reportTypedDictNotRequiredAccess]
419419
except KeyError:
420420
emoji = None
421421

discord/enums.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ def _create_value_cls(name: str, comparable: bool):
8484
# All the type ignores here are due to the type checker being unable to recognise
8585
# Runtime type creation without exploding.
8686
cls = namedtuple('_EnumValue_' + name, 'name value')
87-
cls.__repr__ = lambda self: f'<{name}.{self.name}: {self.value!r}>' # type: ignore
88-
cls.__str__ = lambda self: f'{name}.{self.name}' # type: ignore
87+
cls.__repr__ = lambda self: f'<{name}.{self.name}: {self.value!r}>'
88+
cls.__str__ = lambda self: f'{name}.{self.name}'
8989
if comparable:
90-
cls.__le__ = lambda self, other: isinstance(other, self.__class__) and self.value <= other.value # type: ignore
91-
cls.__ge__ = lambda self, other: isinstance(other, self.__class__) and self.value >= other.value # type: ignore
92-
cls.__lt__ = lambda self, other: isinstance(other, self.__class__) and self.value < other.value # type: ignore
93-
cls.__gt__ = lambda self, other: isinstance(other, self.__class__) and self.value > other.value # type: ignore
90+
cls.__le__ = lambda self, other: isinstance(other, self.__class__) and self.value <= other.value
91+
cls.__ge__ = lambda self, other: isinstance(other, self.__class__) and self.value >= other.value
92+
cls.__lt__ = lambda self, other: isinstance(other, self.__class__) and self.value < other.value
93+
cls.__gt__ = lambda self, other: isinstance(other, self.__class__) and self.value > other.value
9494
return cls
9595

9696

discord/ext/commands/bot.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ def __init__(
172172
**options: Any,
173173
) -> None:
174174
super().__init__(intents=intents, **options)
175-
self.command_prefix: PrefixType[BotT] = command_prefix
175+
self.command_prefix: PrefixType[BotT] = command_prefix # type: ignore
176176
self.extra_events: Dict[str, List[CoroFunc]] = {}
177177
# Self doesn't have the ClientT bound, but since this is a mixin it technically does
178178
self.__tree: app_commands.CommandTree[Self] = tree_cls(self) # type: ignore
@@ -487,7 +487,7 @@ async def can_run(self, ctx: Context[BotT], /, *, call_once: bool = False) -> bo
487487
if len(data) == 0:
488488
return True
489489

490-
return await discord.utils.async_all(f(ctx) for f in data)
490+
return await discord.utils.async_all(f(ctx) for f in data) # type: ignore
491491

492492
async def is_owner(self, user: User, /) -> bool:
493493
"""|coro|

discord/ext/commands/context.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def is_cog(obj: Any) -> TypeGuard[Cog]:
8282
return hasattr(obj, '__cog_commands__')
8383

8484

85-
class DeferTyping:
85+
class DeferTyping(Generic[BotT]):
8686
def __init__(self, ctx: Context[BotT], *, ephemeral: bool):
8787
self.ctx: Context[BotT] = ctx
8888
self.ephemeral: bool = ephemeral

0 commit comments

Comments
 (0)