From 00f0d8afe7a585a78092ddf14d62fabd113da8e3 2019-12-09 21:18:43 From: Matthias Bussonnier Date: 2019-12-09 21:18:43 Subject: [PATCH] Merge pull request #12015 from Carreau/cleanup-imports Cleanup imports, update some deprecation messages. --- diff --git a/IPython/core/completer.py b/IPython/core/completer.py index 4906ae9..0942798 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -126,7 +126,7 @@ import warnings from contextlib import contextmanager from importlib import import_module -from typing import Iterator, List, Tuple, Iterable, Union +from typing import Iterator, List, Tuple, Iterable from types import SimpleNamespace from traitlets.config.configurable import Configurable diff --git a/IPython/core/displaypub.py b/IPython/core/displaypub.py index f651a2a..1da0458 100644 --- a/IPython/core/displaypub.py +++ b/IPython/core/displaypub.py @@ -19,7 +19,7 @@ spec. import sys from traitlets.config.configurable import Configurable -from traitlets import List, Dict +from traitlets import List # This used to be defined here - it is imported for backwards compatibility from .display import publish_display_data diff --git a/IPython/core/interactiveshell.py b/IPython/core/interactiveshell.py index dc8bd23..d8bb3e5 100644 --- a/IPython/core/interactiveshell.py +++ b/IPython/core/interactiveshell.py @@ -13,7 +13,6 @@ import abc import ast -import asyncio import atexit import builtins as builtin_mod import functools @@ -87,6 +86,7 @@ from ast import AST # NoOpContext is deprecated, but ipykernel imports it from here. # See https://github.com/ipython/ipykernel/issues/157 +# (2016, let's try to remove than in IPython 8.0) from IPython.utils.contexts import NoOpContext try: diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py index 906d3d5..5c8649b 100644 --- a/IPython/core/magics/basic.py +++ b/IPython/core/magics/basic.py @@ -5,7 +5,6 @@ import argparse from logging import error import io from pprint import pformat -import textwrap import sys from warnings import warn diff --git a/IPython/core/magics/packaging.py b/IPython/core/magics/packaging.py index 6477c7d..cfee786 100644 --- a/IPython/core/magics/packaging.py +++ b/IPython/core/magics/packaging.py @@ -12,7 +12,6 @@ import os import re import shlex import sys -from subprocess import Popen, PIPE from IPython.core.magic import Magics, magics_class, line_magic @@ -101,4 +100,4 @@ class PackagingMagics(Magics): extra_args.extend(["--prefix", sys.prefix]) self.shell.system(' '.join([conda, command] + extra_args + args)) - print("\nNote: you may need to restart the kernel to use updated packages.") \ No newline at end of file + print("\nNote: you may need to restart the kernel to use updated packages.") diff --git a/IPython/core/tests/refbug.py b/IPython/core/tests/refbug.py index b8de4c8..92e2eea 100644 --- a/IPython/core/tests/refbug.py +++ b/IPython/core/tests/refbug.py @@ -16,7 +16,6 @@ test_run.py calls it. #----------------------------------------------------------------------------- # Module imports #----------------------------------------------------------------------------- -import sys from IPython import get_ipython diff --git a/IPython/core/tests/test_async_helpers.py b/IPython/core/tests/test_async_helpers.py index 2432d8b..2932189 100644 --- a/IPython/core/tests/test_async_helpers.py +++ b/IPython/core/tests/test_async_helpers.py @@ -3,7 +3,6 @@ Test for async helpers. Should only trigger on python 3.5+ or will have syntax errors. """ -import sys from itertools import chain, repeat import nose.tools as nt from textwrap import dedent, indent diff --git a/IPython/core/tests/test_display.py b/IPython/core/tests/test_display.py index 1fed511..0ce4ad2 100644 --- a/IPython/core/tests/test_display.py +++ b/IPython/core/tests/test_display.py @@ -14,7 +14,7 @@ from IPython.core.getipython import get_ipython from IPython.utils.io import capture_output from IPython.utils.tempdir import NamedFileInTemporaryDirectory from IPython import paths as ipath -from IPython.testing.tools import AssertPrints, AssertNotPrints +from IPython.testing.tools import AssertNotPrints import IPython.testing.decorators as dec diff --git a/IPython/core/tests/test_events.py b/IPython/core/tests/test_events.py index db79b4f..a4211ec 100644 --- a/IPython/core/tests/test_events.py +++ b/IPython/core/tests/test_events.py @@ -1,4 +1,3 @@ -from backcall import callback_prototype import unittest from unittest.mock import Mock import nose.tools as nt diff --git a/IPython/core/tests/test_handlers.py b/IPython/core/tests/test_handlers.py index 02860c8..1924817 100644 --- a/IPython/core/tests/test_handlers.py +++ b/IPython/core/tests/test_handlers.py @@ -10,7 +10,6 @@ import nose.tools as nt # our own packages from IPython.core import autocall from IPython.testing import tools as tt -from IPython.utils import py3compat #----------------------------------------------------------------------------- # Globals diff --git a/IPython/extensions/tests/test_autoreload.py b/IPython/extensions/tests/test_autoreload.py index fe62db0..e81bf22 100644 --- a/IPython/extensions/tests/test_autoreload.py +++ b/IPython/extensions/tests/test_autoreload.py @@ -26,8 +26,6 @@ import IPython.testing.tools as tt from unittest import TestCase -from IPython.testing.decorators import skipif - from IPython.extensions.autoreload import AutoreloadMagics from IPython.core.events import EventManager, pre_run_cell @@ -141,7 +139,6 @@ def pickle_get_current_class(obj): class TestAutoreload(Fixture): def test_reload_enums(self): - import enum mod_name, mod_fn = self.new_module(textwrap.dedent(""" from enum import Enum class MyEnum(Enum): diff --git a/IPython/utils/daemonize.py b/IPython/utils/daemonize.py index 0de3852..44b4a28 100644 --- a/IPython/utils/daemonize.py +++ b/IPython/utils/daemonize.py @@ -1,4 +1,4 @@ from warnings import warn -warn("IPython.utils.daemonize has moved to ipyparallel.apps.daemonize", stacklevel=2) +warn("IPython.utils.daemonize has moved to ipyparallel.apps.daemonize since IPython 4.0", DeprecationWarning, stacklevel=2) from ipyparallel.apps.daemonize import daemonize diff --git a/IPython/utils/frame.py b/IPython/utils/frame.py index 11dab31..74c6d41 100644 --- a/IPython/utils/frame.py +++ b/IPython/utils/frame.py @@ -15,7 +15,6 @@ Utilities for working with stack frames. #----------------------------------------------------------------------------- import sys -from IPython.utils import py3compat #----------------------------------------------------------------------------- # Code diff --git a/IPython/utils/tests/test_io.py b/IPython/utils/tests/test_io.py index e6af8c2..83367fa 100644 --- a/IPython/utils/tests/test_io.py +++ b/IPython/utils/tests/test_io.py @@ -5,9 +5,6 @@ # Distributed under the terms of the Modified BSD License. -import io as stdlib_io -import os.path -import stat import sys from io import StringIO @@ -16,9 +13,7 @@ import unittest import nose.tools as nt -from IPython.testing.decorators import skipif, skip_win32 from IPython.utils.io import IOStream, Tee, capture_output -from IPython.utils.tempdir import TemporaryDirectory def test_tee_simple(): diff --git a/IPython/utils/tests/test_path.py b/IPython/utils/tests/test_path.py index 987177b..74f21c3 100644 --- a/IPython/utils/tests/test_path.py +++ b/IPython/utils/tests/test_path.py @@ -21,9 +21,9 @@ import IPython from IPython import paths from IPython.testing import decorators as dec from IPython.testing.decorators import (skip_if_not_win32, skip_win32, - onlyif_unicode_paths, skipif, + onlyif_unicode_paths, skip_win32_py38,) -from IPython.testing.tools import make_tempfile, AssertPrints +from IPython.testing.tools import make_tempfile from IPython.utils import path from IPython.utils.tempdir import TemporaryDirectory diff --git a/IPython/utils/tests/test_process.py b/IPython/utils/tests/test_process.py index 956b2ab..0c81138 100644 --- a/IPython/utils/tests/test_process.py +++ b/IPython/utils/tests/test_process.py @@ -16,7 +16,6 @@ Tests for platutils.py import sys import os -from unittest import TestCase import nose.tools as nt