aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosh <[email protected]>2021-05-06 00:29:07 +1000
committerGitHub <[email protected]>2021-05-05 10:29:07 -0400
commit7fde57c89a388c94f53a0ab8cb524584179f9d35 (patch)
tree2765bca54e784aaba405ffab806cdc3064eef7df
parentType hint colour.py (diff)
downloaddiscord.py-7fde57c89a388c94f53a0ab8cb524584179f9d35.tar.xz
discord.py-7fde57c89a388c94f53a0ab8cb524584179f9d35.zip
Type-hint object.py
-rw-r--r--discord/object.py18
1 files changed, 15 insertions, 3 deletions
diff --git a/discord/object.py b/discord/object.py
index 8ea5293d..3795425f 100644
--- a/discord/object.py
+++ b/discord/object.py
@@ -22,9 +22,21 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
"""
+from __future__ import annotations
+
from . import utils
from .mixins import Hashable
+from typing import (
+ SupportsInt,
+ TYPE_CHECKING,
+ Union,
+)
+
+if TYPE_CHECKING:
+ import datetime
+ SupportsIntCast = Union[SupportsInt, str, bytes, bytearray]
+
__all__ = (
'Object',
)
@@ -63,7 +75,7 @@ class Object(Hashable):
The ID of the object.
"""
- def __init__(self, id):
+ def __init__(self, id: SupportsIntCast):
try:
id = int(id)
except ValueError:
@@ -71,10 +83,10 @@ class Object(Hashable):
else:
self.id = id
- def __repr__(self):
+ def __repr__(self) -> str:
return f'<Object id={self.id!r}>'
@property
- def created_at(self):
+ def created_at(self) -> datetime.datetime:
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
return utils.snowflake_time(self.id)