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
|
import asyncio
|
||||||
from collections import namedtuple
|
|
||||||
import logging
|
import logging
|
||||||
import signal
|
import signal
|
||||||
import sys
|
import sys
|
||||||
|
@ -25,13 +25,12 @@ DEALINGS IN THE SOFTWARE.
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
from collections import namedtuple
|
|
||||||
from .utils import _get_as_snowflake, get, parse_time
|
from .utils import _get_as_snowflake, get, parse_time
|
||||||
from .user import User
|
from .user import User
|
||||||
from .errors import InvalidArgument
|
from .errors import InvalidArgument
|
||||||
from .enums import try_enum, ExpireBehaviour
|
from .enums import try_enum, ExpireBehaviour
|
||||||
|
|
||||||
class IntegrationAccount(namedtuple('IntegrationAccount', 'id name')):
|
class IntegrationAccount:
|
||||||
"""Represents an integration account.
|
"""Represents an integration account.
|
||||||
|
|
||||||
.. versionadded:: 1.4
|
.. versionadded:: 1.4
|
||||||
@ -44,7 +43,11 @@ class IntegrationAccount(namedtuple('IntegrationAccount', 'id name')):
|
|||||||
The account 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):
|
def __repr__(self):
|
||||||
return '<IntegrationAccount id={0.id} name={0.name!r}>'.format(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 .object import Object
|
||||||
from .mixins import Hashable
|
from .mixins import Hashable
|
||||||
from .enums import ChannelType, VerificationLevel, try_enum
|
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.
|
"""Represents a "partial" invite channel.
|
||||||
|
|
||||||
This model will be given when the user is not part of the
|
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.
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<PartialInviteChannel id={0.id} name={0.name} type={0.type!r}>'.format(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mention(self):
|
def mention(self):
|
||||||
""":class:`str`: The string that allows you to mention the channel."""
|
""":class:`str`: The string that allows you to mention the channel."""
|
||||||
@ -154,7 +161,7 @@ class PartialInviteGuild:
|
|||||||
def icon_url(self):
|
def icon_url(self):
|
||||||
""":class:`Asset`: Returns the guild's icon asset."""
|
""":class:`Asset`: Returns the guild's icon asset."""
|
||||||
return self.icon_url_as()
|
return self.icon_url_as()
|
||||||
|
|
||||||
def is_icon_animated(self):
|
def is_icon_animated(self):
|
||||||
""":class:`bool`: Returns ``True`` if the guild has an animated icon.
|
""":class:`bool`: Returns ``True`` if the guild has an animated icon.
|
||||||
|
|
||||||
|
@ -29,9 +29,8 @@ from .user import BaseUser
|
|||||||
from .activity import create_activity
|
from .activity import create_activity
|
||||||
from .invite import Invite
|
from .invite import Invite
|
||||||
from .enums import Status, try_enum
|
from .enums import Status, try_enum
|
||||||
from collections import namedtuple
|
|
||||||
|
|
||||||
class WidgetChannel(namedtuple('WidgetChannel', 'id name position')):
|
class WidgetChannel:
|
||||||
"""Represents a "partial" widget channel.
|
"""Represents a "partial" widget channel.
|
||||||
|
|
||||||
.. container:: operations
|
.. container:: operations
|
||||||
@ -61,11 +60,20 @@ class WidgetChannel(namedtuple('WidgetChannel', 'id name position')):
|
|||||||
position: :class:`int`
|
position: :class:`int`
|
||||||
The channel's position
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return '<WidgetChannel id={0.id} name={0.name!r} position={0.position!r}>'.format(self)
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def mention(self):
|
def mention(self):
|
||||||
""":class:`str`: The string that allows you to mention the channel."""
|
""":class:`str`: The string that allows you to mention the channel."""
|
||||||
|
Loading…
x
Reference in New Issue
Block a user