From 6b803acde4f6377b8ccad959350a61a3d524b619 Mon Sep 17 00:00:00 2001 From: Nadir Chowdhury Date: Sat, 28 Nov 2020 08:16:49 +0000 Subject: [PATCH] [chore] Remove redundant imports This also removes the historical patch for NullHandler implemented in bbf1c54, as it has been available since Python 3.1. --- discord/__init__.py | 9 +-------- discord/abc.py | 2 +- discord/client.py | 2 -- discord/ext/commands/bot.py | 3 +-- discord/guild.py | 3 +-- discord/iterators.py | 2 +- discord/member.py | 2 +- discord/message.py | 1 - discord/state.py | 2 -- discord/utils.py | 2 -- 10 files changed, 6 insertions(+), 22 deletions(-) diff --git a/discord/__init__.py b/discord/__init__.py index 802f4caed..1720f4943 100644 --- a/discord/__init__.py +++ b/discord/__init__.py @@ -64,11 +64,4 @@ VersionInfo = namedtuple('VersionInfo', 'major minor micro releaselevel serial') version_info = VersionInfo(major=1, minor=6, micro=0, releaselevel='alpha', serial=0) -try: - from logging import NullHandler -except ImportError: - class NullHandler(logging.Handler): - def emit(self, record): - pass - -logging.getLogger(__name__).addHandler(NullHandler()) +logging.getLogger(__name__).addHandler(logging.NullHandler()) diff --git a/discord/abc.py b/discord/abc.py index 559dbde82..84757fcb0 100644 --- a/discord/abc.py +++ b/discord/abc.py @@ -32,7 +32,7 @@ import asyncio from .iterators import HistoryIterator from .context_managers import Typing from .enums import ChannelType -from .errors import InvalidArgument, ClientException, HTTPException +from .errors import InvalidArgument, ClientException from .permissions import PermissionOverwrite, Permissions from .role import Role from .invite import Invite diff --git a/discord/client.py b/discord/client.py index a5bb9c002..6f9cb80a0 100644 --- a/discord/client.py +++ b/discord/client.py @@ -33,14 +33,12 @@ import traceback import aiohttp from .user import User, Profile -from .asset import Asset from .invite import Invite from .template import Template from .widget import Widget from .guild import Guild from .channel import _channel_factory from .enums import ChannelType -from .member import Member from .mentions import AllowedMentions from .errors import * from .enums import Status, VoiceRegion diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index c858ab6a9..2fc08fa2a 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -30,12 +30,11 @@ import inspect import importlib.util import sys import traceback -import re import types import discord -from .core import GroupMixin, Command +from .core import GroupMixin from .view import StringView from .context import Context from . import errors diff --git a/discord/guild.py b/discord/guild.py index 514de733f..b781a360d 100644 --- a/discord/guild.py +++ b/discord/guild.py @@ -30,14 +30,13 @@ from collections import namedtuple from . import utils from .role import Role from .member import Member, VoiceState -from .activity import create_activity from .emoji import Emoji from .errors import InvalidData from .permissions import PermissionOverwrite from .colour import Colour from .errors import InvalidArgument, ClientException from .channel import * -from .enums import VoiceRegion, Status, ChannelType, try_enum, VerificationLevel, ContentFilter, NotificationLevel +from .enums import VoiceRegion, ChannelType, try_enum, VerificationLevel, ContentFilter, NotificationLevel from .mixins import Hashable from .user import User from .invite import Invite diff --git a/discord/iterators.py b/discord/iterators.py index b059ea510..34dcd4126 100644 --- a/discord/iterators.py +++ b/discord/iterators.py @@ -28,7 +28,7 @@ import asyncio import datetime from .errors import NoMoreItems -from .utils import DISCORD_EPOCH, time_snowflake, maybe_coroutine +from .utils import time_snowflake, maybe_coroutine from .object import Object from .audit_logs import AuditLogEntry diff --git a/discord/member.py b/discord/member.py index 59bd7bda5..904c76a34 100644 --- a/discord/member.py +++ b/discord/member.py @@ -34,7 +34,7 @@ from . import utils from .user import BaseUser, User from .activity import create_activity from .permissions import Permissions -from .enums import Status, try_enum, UserFlags, HypeSquadHouse +from .enums import Status, try_enum from .colour import Colour from .object import Object diff --git a/discord/message.py b/discord/message.py index ddcb7257d..fb033965c 100644 --- a/discord/message.py +++ b/discord/message.py @@ -43,7 +43,6 @@ from .file import File from .utils import escape_mentions from .guild import Guild from .mixins import Hashable -from .mentions import AllowedMentions from .sticker import Sticker __all__ = ( diff --git a/discord/state.py b/discord/state.py index 6650ba87f..983577aba 100644 --- a/discord/state.py +++ b/discord/state.py @@ -30,7 +30,6 @@ import copy import datetime import itertools import logging -import math import weakref import warnings import inspect @@ -53,7 +52,6 @@ from .role import Role from .enums import ChannelType, try_enum, Status from . import utils from .flags import Intents, MemberCacheFlags -from .embeds import Embed from .object import Object from .invite import Invite diff --git a/discord/utils.py b/discord/utils.py index 56ac6699f..fd24eaeec 100644 --- a/discord/utils.py +++ b/discord/utils.py @@ -31,7 +31,6 @@ import unicodedata from base64 import b64encode from bisect import bisect_left import datetime -from email.utils import parsedate_to_datetime import functools from inspect import isawaitable as _isawaitable from operator import attrgetter @@ -40,7 +39,6 @@ import re import warnings from .errors import InvalidArgument -from .object import Object DISCORD_EPOCH = 1420070400000 MAX_ASYNCIO_SECONDS = 3456000