Skip to content

Commit fa0efba

Browse files
committed
usage of literal None
1 parent 543dec8 commit fa0efba

File tree

3 files changed

+9
-7
lines changed

3 files changed

+9
-7
lines changed

discord/client.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
Sequence,
4141
TypeVar,
4242
overload,
43+
Literal,
4344
)
4445

4546
import aiohttp
@@ -248,9 +249,9 @@ def __init__(
248249
self.loop: asyncio.AbstractEventLoop = (
249250
asyncio.get_event_loop() if loop is None else loop
250251
)
251-
self._listeners: dict[str, list[tuple[asyncio.Future, Callable[..., bool]]]] = (
252-
{}
253-
)
252+
self._listeners: dict[
253+
str, list[tuple[asyncio.Future, Callable[..., bool]]]
254+
] = {}
254255
self.shard_id: int | None = options.get("shard_id")
255256
self.shard_count: int | None = options.get("shard_count")
256257

@@ -1191,7 +1192,7 @@ async def get_or_fetch_user(self, id: int, /) -> User | None: # TODO: Remove in
11911192
async def get_or_fetch(
11921193
self: Client,
11931194
object_type: type[_FETCHABLE],
1194-
object_id: None,
1195+
object_id: Literal[None],
11951196
default: _D = ...,
11961197
) -> None | _D: ...
11971198

discord/guild.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
Tuple,
3939
Union,
4040
overload,
41+
Literal,
4142
)
4243

4344
from . import abc, utils
@@ -868,7 +869,7 @@ def get_member(self, user_id: int, /) -> Member | None:
868869
async def get_or_fetch(
869870
self: Guild,
870871
object_type: type[_FETCHABLE],
871-
object_id: None,
872+
object_id: Literal[None],
872873
default: _D = ...,
873874
) -> None | _D: ...
874875
@overload

discord/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,7 @@ def get(iterable: Iterable[T], **attrs: Any) -> T | None:
598598
async def get_or_fetch(
599599
obj: Guild | Client,
600600
object_type: type[_FETCHABLE],
601-
object_id: None,
601+
object_id: Literal[None],
602602
default: _D = ...,
603603
attr: str = ...,
604604
id: int = ...,
@@ -782,7 +782,7 @@ async def get_or_fetch(
782782
try:
783783
return await fetcher(obj, object_id)
784784
except (HTTPException, ValueError):
785-
if default is not None:
785+
if default is not MISSING:
786786
return default
787787
raise
788788

0 commit comments

Comments
 (0)