From 4cefda8e483b324a2c951d2909143dd756a62eb7 Mon Sep 17 00:00:00 2001 From: Chromosomologist Date: Thu, 19 Sep 2024 17:01:20 +0200 Subject: [PATCH] fix: replace pipe unions with typing.Union --- docs/source/extensions/custom_documenter.py | 2 +- src/disnake/ext/components/impl/manager.py | 9 ++++++--- src/disnake/ext/components/impl/parser/stdlib.py | 6 +++--- 3 files changed, 10 insertions(+), 7 deletions(-) diff --git a/docs/source/extensions/custom_documenter.py b/docs/source/extensions/custom_documenter.py index e293264..8ef2834 100644 --- a/docs/source/extensions/custom_documenter.py +++ b/docs/source/extensions/custom_documenter.py @@ -124,7 +124,7 @@ def can_document_member( ) -> bool: return isinstance(member, enum.EnumMeta) and not issubclass(member, enum.Flag) - def add_content(self, more_content: autodoc.StringList | None) -> None: + def add_content(self, more_content: typing.Optional[autodoc.StringList]) -> None: super().add_content(more_content) source_name = self.get_sourcename() diff --git a/src/disnake/ext/components/impl/manager.py b/src/disnake/ext/components/impl/manager.py index cc3d679..9a72278 100644 --- a/src/disnake/ext/components/impl/manager.py +++ b/src/disnake/ext/components/impl/manager.py @@ -581,7 +581,10 @@ async def parse_message_components( # Identifier and component: function call, return component @typing.overload def register( - self, component_type: typing.Type[ComponentT], *, identifier: str | None = None + self, + component_type: typing.Type[ComponentT], + *, + identifier: typing.Optional[str] = None, ) -> typing.Type[ComponentT]: ... @@ -589,7 +592,7 @@ def register( # returns the component. @typing.overload def register( - self, *, identifier: str | None = None + self, *, identifier: typing.Optional[str] = None ) -> typing.Callable[[typing.Type[ComponentT]], typing.Type[ComponentT]]: ... @@ -949,7 +952,7 @@ def make_select( # noqa: PLR0913 identifier: str, *, as_root: bool = True, - placeholder: omit.Omissible[str | None] = omit.Omitted, + placeholder: omit.Omissible[typing.Optional[str]] = omit.Omitted, min_values: omit.Omissible[int] = omit.Omitted, max_values: omit.Omissible[int] = omit.Omitted, disabled: omit.Omissible[bool] = omit.Omitted, diff --git a/src/disnake/ext/components/impl/parser/stdlib.py b/src/disnake/ext/components/impl/parser/stdlib.py index d0fa9f1..f67c5eb 100644 --- a/src/disnake/ext/components/impl/parser/stdlib.py +++ b/src/disnake/ext/components/impl/parser/stdlib.py @@ -440,7 +440,7 @@ class DatetimeParser(parser_base.Parser[datetime.datetime]): """ - resolution: int | float + resolution: typing.Union[int, float] r"""The resolution with which to store :class:`~datetime.datetime`\s in seconds. .. warning:: @@ -478,7 +478,7 @@ class DatetimeParser(parser_base.Parser[datetime.datetime]): def __init__( self, *, - resolution: int | float = Resolution.SECONDS, + resolution: typing.Union[int, float] = Resolution.SECONDS, timezone: datetime.timezone = datetime.timezone.utc, strict: bool = True, int_parser: typing.Optional[IntParser] = None, @@ -626,7 +626,7 @@ class TimeParser(parser_base.Parser[datetime.time]): """ - resolution: int | float + resolution: typing.Union[int, float] r"""The resolution with which to store :class:`~datetime.time`\s in seconds. .. warning::