27
27
from __future__ import annotations
28
28
29
29
from typing import (
30
+ Any ,
30
31
Type ,
31
32
Optional ,
32
33
TYPE_CHECKING
33
34
)
34
35
35
36
if TYPE_CHECKING :
37
+ from .abc import Snowflake
36
38
from datetime import datetime
37
39
from .state import ConnectionState
38
40
41
43
42
44
from . import utils
43
45
from .mixins import Hashable
46
+
44
47
MISSING = utils .MISSING
45
48
49
+ __all__ = (
50
+ 'Object' ,
51
+ )
52
+
46
53
47
54
class Object (Hashable ):
48
55
"""Represents a generic Discord object.
@@ -79,11 +86,12 @@ class Object(Hashable):
79
86
type: :class:`object`
80
87
The object this should represent if any.
81
88
"""
89
+ id : int
82
90
83
91
def __init__ (
84
92
self ,
85
93
id : SnowflakeID ,
86
- type : Type = utils . MISSING ,
94
+ type : Type = MISSING ,
87
95
* ,
88
96
state : Optional [ConnectionState ] = MISSING
89
97
):
@@ -98,7 +106,7 @@ def __init__(
98
106
def __repr__ (self ) -> str :
99
107
return f'<Object id={ self .id !r} type={ self .type !r} >'
100
108
101
- def __instancecheck__ (self , other ) -> bool :
109
+ def __instancecheck__ (self , other : Any ) -> bool :
102
110
if self .type is not MISSING :
103
111
return self .type == type (other )
104
112
return self .__class__ == type (other )
@@ -107,3 +115,8 @@ def __instancecheck__(self, other) -> bool:
107
115
def created_at (self ) -> datetime :
108
116
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
109
117
return utils .snowflake_time (self .id )
118
+
119
+
120
+ if TYPE_CHECKING :
121
+ class Object (Snowflake , Object ):
122
+ pass
0 commit comments