From 19b05e632c1ba416b275f9ab0a7d3281c95905e2 Mon Sep 17 00:00:00 2001 From: Tobotimus Date: Sun, 3 Jun 2018 08:24:16 +1000 Subject: [PATCH] [V3] Use typing.TYPE_CHECKING instead of utils.TYPE_CHECKING (#1778) Not needed any more as we no longer support python<3.6 --- redbot/cogs/downloader/installable.py | 5 ++--- redbot/core/config.py | 4 +--- redbot/core/core_commands.py | 3 +-- redbot/core/data_manager.py | 4 ---- redbot/core/utils/__init__.py | 14 +------------- 5 files changed, 5 insertions(+), 25 deletions(-) diff --git a/redbot/cogs/downloader/installable.py b/redbot/cogs/downloader/installable.py index 3247fb2a4..1633f0fbe 100644 --- a/redbot/cogs/downloader/installable.py +++ b/redbot/cogs/downloader/installable.py @@ -3,9 +3,8 @@ import distutils.dir_util import shutil from enum import Enum from pathlib import Path -from typing import MutableMapping, Any +from typing import MutableMapping, Any, TYPE_CHECKING -from redbot.core.utils import TYPE_CHECKING from .log import log from .json_mixins import RepoJSONMixin @@ -25,7 +24,7 @@ class Installable(RepoJSONMixin): - Modules - Repo Libraries - Other stuff? - + The attributes of this class will mostly come from the installation's info.json. diff --git a/redbot/core/config.py b/redbot/core/config.py index a217bc13e..88a31d313 100644 --- a/redbot/core/config.py +++ b/redbot/core/config.py @@ -1,15 +1,13 @@ import logging import collections from copy import deepcopy -from typing import Union, Tuple +from typing import Union, Tuple, TYPE_CHECKING import discord from .data_manager import cog_data_path, core_data_path from .drivers import get_driver -from .utils import TYPE_CHECKING - if TYPE_CHECKING: from .drivers.red_base import BaseDriver diff --git a/redbot/core/core_commands.py b/redbot/core/core_commands.py index b8c62074f..5e6050f69 100644 --- a/redbot/core/core_commands.py +++ b/redbot/core/core_commands.py @@ -13,6 +13,7 @@ from pathlib import Path from random import SystemRandom from string import ascii_letters, digits from distutils.version import StrictVersion +from typing import TYPE_CHECKING import aiohttp import discord @@ -21,9 +22,7 @@ import pkg_resources from redbot.core import __version__ from redbot.core import checks from redbot.core import i18n -from redbot.core import rpc from redbot.core import commands -from .utils import TYPE_CHECKING from .utils.chat_formatting import pagify, box, inline if TYPE_CHECKING: diff --git a/redbot/core/data_manager.py b/redbot/core/data_manager.py index 6c39d9017..23548facf 100644 --- a/redbot/core/data_manager.py +++ b/redbot/core/data_manager.py @@ -9,10 +9,6 @@ import logging import appdirs from .json_io import JsonIO -from .utils import TYPE_CHECKING - -if TYPE_CHECKING: - from . import Config __all__ = [ "load_basic_configuration", diff --git a/redbot/core/utils/__init__.py b/redbot/core/utils/__init__.py index 5fbb8483c..c879fb871 100644 --- a/redbot/core/utils/__init__.py +++ b/redbot/core/utils/__init__.py @@ -1,4 +1,4 @@ -__all__ = ["TYPE_CHECKING", "NewType", "safe_delete", "fuzzy_command_search"] +__all__ = ["safe_delete", "fuzzy_command_search"] from pathlib import Path import os @@ -7,18 +7,6 @@ from redbot.core import commands from fuzzywuzzy import process from .chat_formatting import box -try: - from typing import TYPE_CHECKING -except ImportError: - TYPE_CHECKING = False - -try: - from typing import NewType -except ImportError: - - def NewType(name, tp): - return type(name, (tp,), {}) - def safe_delete(pth: Path): if pth.exists():