@@ -594,44 +594,13 @@ def get(iterable: Iterable[T], **attrs: Any) -> T | None:
594594
595595# TODO: In version 3.0, remove the 'attr' and 'id' arguments.
596596# Also, eliminate the default 'MISSING' value for both 'object_type' and 'object_id'.
597- @overload
598- async def get_or_fetch (
599- obj : Guild | Client ,
600- object_type : type [_FETCHABLE ],
601- object_id : Literal [None ],
602- default : _D = ...,
603- attr : str = ...,
604- id : int = ...,
605- ) -> None | _D : ...
606-
607-
608- @overload
609- async def get_or_fetch (
610- obj : Guild | Client ,
611- object_type : type [_FETCHABLE ],
612- object_id : int ,
613- default : _D ,
614- attr : str = ...,
615- id : int = ...,
616- ) -> _FETCHABLE | _D : ...
617-
618-
619- @overload
620- async def get_or_fetch (
621- obj : Guild | Client ,
622- object_type : type [_FETCHABLE ],
623- object_id : int ,
624- * ,
625- attr : str = ...,
626- id : int = ...,
627- ) -> _FETCHABLE : ...
628597
629598
630599async def get_or_fetch (
631600 obj : Guild | Client ,
632601 object_type : type [_FETCHABLE ] = MISSING ,
633602 object_id : int | None = MISSING ,
634- default : _D = MISSING ,
603+ default : _D = None ,
635604 attr : str = MISSING ,
636605 id : int = MISSING ,
637606) -> _FETCHABLE | _D | None :
@@ -645,7 +614,7 @@ async def get_or_fetch(
645614 object_type: VoiceChannel | TextChannel | ForumChannel | StageChannel | CategoryChannel | Thread | User | Guild | Role | Member | GuildEmoji | AppEmoji
646615 Type of object to fetch or get.
647616
648- object_id: :class:` int`
617+ object_id: int | None
649618 ID of object to get.
650619
651620 default : Any | None
@@ -656,20 +625,6 @@ async def get_or_fetch(
656625
657626 VoiceChannel | TextChannel | ForumChannel | StageChannel | CategoryChannel | Thread | User | Guild | Role | Member | GuildEmoji | AppEmoji | None
658627 The object if found, or `default` if provided when not found.
659- Returns `None` only if `object_id` is None and no `default` is given.
660-
661- Raises
662- ------
663- :exc:`TypeError`
664- Raised when required parameters are missing or invalid types are provided.
665- :exc:`InvalidArgument`
666- Raised when an unsupported or incompatible object type is used.
667- :exc:`NotFound`
668- Invalid ID for the object.
669- :exc:`HTTPException`
670- An error occurred fetching the object.
671- :exc:`Forbidden`
672- You do not have permission to fetch the object.
673628 """
674629 from discord import AppEmoji , Client , Guild , Member , Role , User , abc , emoji
675630
@@ -782,9 +737,7 @@ async def get_or_fetch(
782737 try :
783738 return await fetcher (obj , object_id )
784739 except (HTTPException , ValueError ):
785- if default is not MISSING :
786- return default
787- raise
740+ return default
788741
789742
790743def _unique (iterable : Iterable [T ]) -> list [T ]:
0 commit comments