From f49d565d5130c1de687f1f315686e81d4a71ca4a Mon Sep 17 00:00:00 2001 From: Rapptz Date: Wed, 7 Apr 2021 05:50:54 -0400 Subject: Rename discord.types file based on relevant core module file --- discord/embeds.py | 2 +- discord/types/common.py | 86 ------------------------------------------------- discord/types/embed.py | 84 +++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 85 insertions(+), 87 deletions(-) delete mode 100644 discord/types/common.py create mode 100644 discord/types/embed.py (limited to 'discord') diff --git a/discord/embeds.py b/discord/embeds.py index c44d8b9e..d08c9874 100644 --- a/discord/embeds.py +++ b/discord/embeds.py @@ -67,7 +67,7 @@ class EmbedProxy: E = TypeVar('E', bound='Embed') if TYPE_CHECKING: - from discord.types.common import Embed as EmbedData, EmbedType + from discord.types.embed import Embed as EmbedData, EmbedType T = TypeVar('T') MaybeEmpty = Union[T, _EmptyEmbed] diff --git a/discord/types/common.py b/discord/types/common.py deleted file mode 100644 index 4b4a3e8f..00000000 --- a/discord/types/common.py +++ /dev/null @@ -1,86 +0,0 @@ -""" -The MIT License (MIT) - -Copyright (c) 2015-present Rapptz - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -the rights to use, copy, modify, merge, publish, distribute, sublicense, -and/or sell copies of the Software, and to permit persons to whom the -Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -DEALINGS IN THE SOFTWARE. -""" - -# This file provides typings for shared entities between the Gateway and HTTP API - -from typing import List, Literal, TypedDict - -class _EmbedFooterOptional(TypedDict, total=False): - icon_url: str - proxy_icon_url: str - -class EmbedFooter(_EmbedFooterOptional): - text: str - -class _EmbedFieldOptional(TypedDict, total=False): - inline: bool - -class EmbedField(_EmbedFieldOptional): - name: str - value: str - -class EmbedThumbnail(TypedDict, total=False): - url: str - proxy_url: str - height: int - width: int - -class EmbedVideo(TypedDict, total=False): - url: str - proxy_url: str - height: int - width: int - -class EmbedImage(TypedDict, total=False): - url: str - proxy_url: str - height: int - width: int - -class EmbedProvider(TypedDict, total=False): - name: str - url: str - -class EmbedAuthor(TypedDict, total=False): - name: str - url: str - icon_url: str - proxy_icon_url: str - -EmbedType = Literal['rich', 'image', 'video', 'gifv', 'article', 'link'] - -class Embed(TypedDict, total=False): - title: str - type: EmbedType - description: str - url: str - timestamp: str - color: int - footer: EmbedFooter - image: EmbedImage - thumbnail: EmbedThumbnail - video: EmbedVideo - provider: EmbedProvider - author: EmbedAuthor - fields: List[EmbedField] diff --git a/discord/types/embed.py b/discord/types/embed.py new file mode 100644 index 00000000..b38c9314 --- /dev/null +++ b/discord/types/embed.py @@ -0,0 +1,84 @@ +""" +The MIT License (MIT) + +Copyright (c) 2015-present Rapptz + +Permission is hereby granted, free of charge, to any person obtaining a +copy of this software and associated documentation files (the "Software"), +to deal in the Software without restriction, including without limitation +the rights to use, copy, modify, merge, publish, distribute, sublicense, +and/or sell copies of the Software, and to permit persons to whom the +Software is furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. +""" + +from typing import List, Literal, TypedDict + +class _EmbedFooterOptional(TypedDict, total=False): + icon_url: str + proxy_icon_url: str + +class EmbedFooter(_EmbedFooterOptional): + text: str + +class _EmbedFieldOptional(TypedDict, total=False): + inline: bool + +class EmbedField(_EmbedFieldOptional): + name: str + value: str + +class EmbedThumbnail(TypedDict, total=False): + url: str + proxy_url: str + height: int + width: int + +class EmbedVideo(TypedDict, total=False): + url: str + proxy_url: str + height: int + width: int + +class EmbedImage(TypedDict, total=False): + url: str + proxy_url: str + height: int + width: int + +class EmbedProvider(TypedDict, total=False): + name: str + url: str + +class EmbedAuthor(TypedDict, total=False): + name: str + url: str + icon_url: str + proxy_icon_url: str + +EmbedType = Literal['rich', 'image', 'video', 'gifv', 'article', 'link'] + +class Embed(TypedDict, total=False): + title: str + type: EmbedType + description: str + url: str + timestamp: str + color: int + footer: EmbedFooter + image: EmbedImage + thumbnail: EmbedThumbnail + video: EmbedVideo + provider: EmbedProvider + author: EmbedAuthor + fields: List[EmbedField] -- cgit v1.2.3