mirror of
https://github.com/Rapptz/discord.py.git
synced 2025-05-16 18:59:09 +00:00
Remove namedtuples to better future guard the library
This commit is contained in:
parent
e7b4bbe2f6
commit
7f17dc79a6
@ -25,7 +25,6 @@ DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
import asyncio
|
||||
from collections import namedtuple
|
||||
import logging
|
||||
import signal
|
||||
import sys
|
||||
|
@ -25,13 +25,12 @@ DEALINGS IN THE SOFTWARE.
|
||||
"""
|
||||
|
||||
import datetime
|
||||
from collections import namedtuple
|
||||
from .utils import _get_as_snowflake, get, parse_time
|
||||
from .user import User
|
||||
from .errors import InvalidArgument
|
||||
from .enums import try_enum, ExpireBehaviour
|
||||
|
||||
class IntegrationAccount(namedtuple('IntegrationAccount', 'id name')):
|
||||
class IntegrationAccount:
|
||||
"""Represents an integration account.
|
||||
|
||||
.. versionadded:: 1.4
|
||||
@ -44,7 +43,11 @@ class IntegrationAccount(namedtuple('IntegrationAccount', 'id name')):
|
||||
The account name.
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
__slots__ = ('id', 'name')
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.pop('id')
|
||||
self.name = kwargs.pop('name')
|
||||
|
||||
def __repr__(self):
|
||||
return '<IntegrationAccount id={0.id} name={0.name!r}>'.format(self)
|
||||
|
@ -29,9 +29,8 @@ from .utils import parse_time, snowflake_time, _get_as_snowflake
|
||||
from .object import Object
|
||||
from .mixins import Hashable
|
||||
from .enums import ChannelType, VerificationLevel, try_enum
|
||||
from collections import namedtuple
|
||||
|
||||
class PartialInviteChannel(namedtuple('PartialInviteChannel', 'id name type')):
|
||||
class PartialInviteChannel:
|
||||
"""Represents a "partial" invite channel.
|
||||
|
||||
This model will be given when the user is not part of the
|
||||
@ -65,11 +64,19 @@ class PartialInviteChannel(namedtuple('PartialInviteChannel', 'id name type')):
|
||||
The partial channel's type.
|
||||
"""
|
||||
|
||||
__slots__ = ()
|
||||
__slots__ = ('id', 'name', 'type')
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.pop('id')
|
||||
self.name = kwargs.pop('name')
|
||||
self.type = kwargs.pop('type')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return '<PartialInviteChannel id={0.id} name={0.name} type={0.type!r}>'.format(self)
|
||||
|
||||
@property
|
||||
def mention(self):
|
||||
""":class:`str`: The string that allows you to mention the channel."""
|
||||
|
@ -29,9 +29,8 @@ from .user import BaseUser
|
||||
from .activity import create_activity
|
||||
from .invite import Invite
|
||||
from .enums import Status, try_enum
|
||||
from collections import namedtuple
|
||||
|
||||
class WidgetChannel(namedtuple('WidgetChannel', 'id name position')):
|
||||
class WidgetChannel:
|
||||
"""Represents a "partial" widget channel.
|
||||
|
||||
.. container:: operations
|
||||
@ -61,11 +60,20 @@ class WidgetChannel(namedtuple('WidgetChannel', 'id name position')):
|
||||
position: :class:`int`
|
||||
The channel's position
|
||||
"""
|
||||
__slots__ = ()
|
||||
__slots__ = ('id', 'name', 'position')
|
||||
|
||||
|
||||
def __init__(self, **kwargs):
|
||||
self.id = kwargs.pop('id')
|
||||
self.name = kwargs.pop('name')
|
||||
self.position = kwargs.pop('position')
|
||||
|
||||
def __str__(self):
|
||||
return self.name
|
||||
|
||||
def __repr__(self):
|
||||
return '<WidgetChannel id={0.id} name={0.name!r} position={0.position!r}>'.format(self)
|
||||
|
||||
@property
|
||||
def mention(self):
|
||||
""":class:`str`: The string that allows you to mention the channel."""
|
||||
|
Loading…
x
Reference in New Issue
Block a user