mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-07-06 18:11:59 +00:00
Type-hint object.py
This commit is contained in:
parent
c69b20c52c
commit
7fde57c89a
@ -22,9 +22,21 @@ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
|||||||
DEALINGS IN THE SOFTWARE.
|
DEALINGS IN THE SOFTWARE.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
from __future__ import annotations
|
||||||
|
|
||||||
from . import utils
|
from . import utils
|
||||||
from .mixins import Hashable
|
from .mixins import Hashable
|
||||||
|
|
||||||
|
from typing import (
|
||||||
|
SupportsInt,
|
||||||
|
TYPE_CHECKING,
|
||||||
|
Union,
|
||||||
|
)
|
||||||
|
|
||||||
|
if TYPE_CHECKING:
|
||||||
|
import datetime
|
||||||
|
SupportsIntCast = Union[SupportsInt, str, bytes, bytearray]
|
||||||
|
|
||||||
__all__ = (
|
__all__ = (
|
||||||
'Object',
|
'Object',
|
||||||
)
|
)
|
||||||
@ -63,7 +75,7 @@ class Object(Hashable):
|
|||||||
The ID of the object.
|
The ID of the object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, id):
|
def __init__(self, id: SupportsIntCast):
|
||||||
try:
|
try:
|
||||||
id = int(id)
|
id = int(id)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -71,10 +83,10 @@ class Object(Hashable):
|
|||||||
else:
|
else:
|
||||||
self.id = id
|
self.id = id
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self) -> str:
|
||||||
return f'<Object id={self.id!r}>'
|
return f'<Object id={self.id!r}>'
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def created_at(self):
|
def created_at(self) -> datetime.datetime:
|
||||||
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
|
""":class:`datetime.datetime`: Returns the snowflake's creation time in UTC."""
|
||||||
return utils.snowflake_time(self.id)
|
return utils.snowflake_time(self.id)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user