From aefe51c6071e045e00ed87fa5ef995eca17105f5 2022-09-01 11:09:25 From: Matthias Bussonnier Date: 2022-09-01 11:09:25 Subject: [PATCH] try ruff to find unused imports --- diff --git a/IPython/__init__.py b/IPython/__init__.py index b5410f6..03b3116 100644 --- a/IPython/__init__.py +++ b/IPython/__init__.py @@ -18,7 +18,6 @@ https://ipython.org # Imports #----------------------------------------------------------------------------- -import os import sys #----------------------------------------------------------------------------- diff --git a/IPython/core/application.py b/IPython/core/application.py index 0cdea5c..26c0616 100644 --- a/IPython/core/application.py +++ b/IPython/core/application.py @@ -14,7 +14,6 @@ object and then create the configurable objects, passing the config to them. import atexit from copy import deepcopy -import glob import logging import os import shutil diff --git a/IPython/core/crashhandler.py b/IPython/core/crashhandler.py index 4af3936..f60a75b 100644 --- a/IPython/core/crashhandler.py +++ b/IPython/core/crashhandler.py @@ -19,7 +19,6 @@ Authors: # Imports #----------------------------------------------------------------------------- -import os import sys import traceback from pprint import pformat diff --git a/IPython/core/debugger.py b/IPython/core/debugger.py index ba12e3e..73b0328 100644 --- a/IPython/core/debugger.py +++ b/IPython/core/debugger.py @@ -104,7 +104,6 @@ All the changes since then are under the same license as IPython. import inspect import linecache import sys -import warnings import re import os diff --git a/IPython/core/excolors.py b/IPython/core/excolors.py index c47ce92..85eef81 100644 --- a/IPython/core/excolors.py +++ b/IPython/core/excolors.py @@ -4,7 +4,6 @@ Color schemes for exception handling code in IPython. """ import os -import warnings #***************************************************************************** # Copyright (C) 2005-2006 Fernando Perez diff --git a/IPython/core/formatters.py b/IPython/core/formatters.py index 4e0b9e4..e7aa6f3 100644 --- a/IPython/core/formatters.py +++ b/IPython/core/formatters.py @@ -11,7 +11,6 @@ Inheritance diagram: # Distributed under the terms of the Modified BSD License. import abc -import json import sys import traceback import warnings diff --git a/IPython/core/inputtransformer2.py b/IPython/core/inputtransformer2.py index a8f676f..e4e385a 100644 --- a/IPython/core/inputtransformer2.py +++ b/IPython/core/inputtransformer2.py @@ -11,7 +11,6 @@ deprecated in 7.0. # Distributed under the terms of the Modified BSD License. import ast -import sys from codeop import CommandCompiler, Compile import re import tokenize diff --git a/IPython/core/magics/basic.py b/IPython/core/magics/basic.py index ea407c6..af69b02 100644 --- a/IPython/core/magics/basic.py +++ b/IPython/core/magics/basic.py @@ -1,7 +1,6 @@ """Implementation of basic magic functions.""" -import argparse from logging import error import io import os diff --git a/IPython/core/oinspect.py b/IPython/core/oinspect.py index 1a5c0ae..f1c454b 100644 --- a/IPython/core/oinspect.py +++ b/IPython/core/oinspect.py @@ -31,7 +31,6 @@ from IPython.lib.pretty import pretty from IPython.testing.skipdoctest import skip_doctest from IPython.utils import PyColorize from IPython.utils import openpy -from IPython.utils import py3compat from IPython.utils.dir2 import safe_hasattr from IPython.utils.path import compress_user from IPython.utils.text import indent diff --git a/IPython/core/shellapp.py b/IPython/core/shellapp.py index f737bcb..180f8b1 100644 --- a/IPython/core/shellapp.py +++ b/IPython/core/shellapp.py @@ -19,7 +19,6 @@ from IPython.core.application import SYSTEM_CONFIG_DIRS, ENV_CONFIG_DIRS from IPython.core import pylabtools from IPython.utils.contexts import preserve_keys from IPython.utils.path import filefind -import traitlets from traitlets import ( Unicode, Instance, List, Bool, CaselessStrEnum, observe, DottedObjectName, diff --git a/IPython/core/tests/test_compilerop.py b/IPython/core/tests/test_compilerop.py index b939bb6..8a5c9dc 100644 --- a/IPython/core/tests/test_compilerop.py +++ b/IPython/core/tests/test_compilerop.py @@ -17,9 +17,6 @@ import linecache import sys -# Third-party imports -import pytest - # Our own imports from IPython.core import compilerop diff --git a/IPython/core/tests/test_debugger.py b/IPython/core/tests/test_debugger.py index 5a12c3b..5f7f98d 100644 --- a/IPython/core/tests/test_debugger.py +++ b/IPython/core/tests/test_debugger.py @@ -4,7 +4,6 @@ # Copyright (c) IPython Development Team. # Distributed under the terms of the Modified BSD License. -import bdb import builtins import os import sys diff --git a/IPython/core/tests/test_formatters.py b/IPython/core/tests/test_formatters.py index 26d3583..c642bef 100644 --- a/IPython/core/tests/test_formatters.py +++ b/IPython/core/tests/test_formatters.py @@ -1,6 +1,5 @@ """Tests for the Formatters.""" -import warnings from math import pi try: diff --git a/IPython/core/tests/test_history.py b/IPython/core/tests/test_history.py index a9ebafd..fa64fe0 100644 --- a/IPython/core/tests/test_history.py +++ b/IPython/core/tests/test_history.py @@ -7,7 +7,6 @@ # stdlib import io -import sqlite3 import sys import tempfile from datetime import datetime diff --git a/IPython/core/tests/test_inputtransformer2_line.py b/IPython/core/tests/test_inputtransformer2_line.py index 30558fd..ec7a873 100644 --- a/IPython/core/tests/test_inputtransformer2_line.py +++ b/IPython/core/tests/test_inputtransformer2_line.py @@ -3,7 +3,6 @@ Line-based transformers are the simpler ones; token-based transformers are more complex. See test_inputtransformer2 for tests for token-based transformers. """ -import pytest from IPython.core import inputtransformer2 as ipt2 diff --git a/IPython/core/tests/test_iplib.py b/IPython/core/tests/test_iplib.py index 14474bb..f126018 100644 --- a/IPython/core/tests/test_iplib.py +++ b/IPython/core/tests/test_iplib.py @@ -4,8 +4,6 @@ # Module imports #----------------------------------------------------------------------------- -# third party -import pytest # our own packages diff --git a/IPython/core/tests/test_magic.py b/IPython/core/tests/test_magic.py index 850e227..1c793ca 100644 --- a/IPython/core/tests/test_magic.py +++ b/IPython/core/tests/test_magic.py @@ -1,7 +1,6 @@ # -*- coding: utf-8 -*- """Tests for various magic functions.""" -import asyncio import gc import io import os diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index eb754b8..86367b6 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -1,7 +1,6 @@ import errno import os import shutil -import sys import tempfile import warnings from unittest.mock import patch diff --git a/IPython/core/tests/test_pylabtools.py b/IPython/core/tests/test_pylabtools.py index 7888637..59bf3bc 100644 --- a/IPython/core/tests/test_pylabtools.py +++ b/IPython/core/tests/test_pylabtools.py @@ -155,9 +155,6 @@ def test_import_pylab(): assert ns["np"] == np -from traitlets.config import Config - - class TestPylabSwitch(object): class Shell(InteractiveShell): def init_history(self): diff --git a/IPython/core/tests/test_ultratb.py b/IPython/core/tests/test_ultratb.py index 1f49603..349d2ac 100644 --- a/IPython/core/tests/test_ultratb.py +++ b/IPython/core/tests/test_ultratb.py @@ -2,7 +2,6 @@ """Tests for IPython.core.ultratb """ import io -import logging import os.path import platform import re diff --git a/IPython/lib/latextools.py b/IPython/lib/latextools.py index b90a5d7..693060b 100644 --- a/IPython/lib/latextools.py +++ b/IPython/lib/latextools.py @@ -12,7 +12,7 @@ import subprocess from base64 import encodebytes import textwrap -from pathlib import Path, PurePath +from pathlib import Path from IPython.utils.process import find_cmd, FindCmdError from traitlets.config import get_config diff --git a/IPython/paths.py b/IPython/paths.py index 4fd253c..cc6408c 100644 --- a/IPython/paths.py +++ b/IPython/paths.py @@ -1,7 +1,6 @@ """Find files and directories which IPython uses. """ import os.path -import shutil import tempfile from warnings import warn diff --git a/IPython/testing/decorators.py b/IPython/testing/decorators.py index 644a513..af42f34 100644 --- a/IPython/testing/decorators.py +++ b/IPython/testing/decorators.py @@ -36,7 +36,6 @@ import shutil import sys import tempfile import unittest -import warnings from importlib import import_module from decorator import decorator diff --git a/IPython/testing/globalipapp.py b/IPython/testing/globalipapp.py index 698e3d8..3a699e0 100644 --- a/IPython/testing/globalipapp.py +++ b/IPython/testing/globalipapp.py @@ -12,7 +12,6 @@ done. import builtins as builtin_mod import sys import types -import warnings from pathlib import Path diff --git a/IPython/testing/plugin/ipdoctest.py b/IPython/testing/plugin/ipdoctest.py index 52cd8fd..e7edf98 100644 --- a/IPython/testing/plugin/ipdoctest.py +++ b/IPython/testing/plugin/ipdoctest.py @@ -21,7 +21,6 @@ Limitations: # From the standard library import doctest import logging -import os import re from testpath import modified_env diff --git a/IPython/tests/cve.py b/IPython/tests/cve.py index 0a9dec4..fd1b807 100644 --- a/IPython/tests/cve.py +++ b/IPython/tests/cve.py @@ -9,7 +9,6 @@ import sys import os import string import subprocess -import time def test_cve_2022_21699(): diff --git a/IPython/utils/io.py b/IPython/utils/io.py index 170bc62..2eac5e6 100644 --- a/IPython/utils/io.py +++ b/IPython/utils/io.py @@ -12,7 +12,6 @@ import atexit import os import sys import tempfile -import warnings from pathlib import Path from warnings import warn diff --git a/IPython/utils/module_paths.py b/IPython/utils/module_paths.py index f9f7cac..6f8cb10 100644 --- a/IPython/utils/module_paths.py +++ b/IPython/utils/module_paths.py @@ -17,7 +17,6 @@ Utility functions for finding modules on sys.path. # Stdlib imports import importlib -import os import sys # Third-party imports diff --git a/IPython/utils/path.py b/IPython/utils/path.py index a3a417d..ccb70dc 100644 --- a/IPython/utils/path.py +++ b/IPython/utils/path.py @@ -12,10 +12,8 @@ import errno import shutil import random import glob -from warnings import warn from IPython.utils.process import system -from IPython.utils.decorators import undoc #----------------------------------------------------------------------------- # Code diff --git a/IPython/utils/tests/test_io.py b/IPython/utils/tests/test_io.py index 3b4c03e..75d895e 100644 --- a/IPython/utils/tests/test_io.py +++ b/IPython/utils/tests/test_io.py @@ -8,7 +8,6 @@ import sys from io import StringIO -from subprocess import Popen, PIPE import unittest from IPython.utils.io import Tee, capture_output diff --git a/IPython/utils/tests/test_module_paths.py b/IPython/utils/tests/test_module_paths.py index 8438a1e..8dc52fd 100644 --- a/IPython/utils/tests/test_module_paths.py +++ b/IPython/utils/tests/test_module_paths.py @@ -18,8 +18,6 @@ import tempfile from pathlib import Path -from IPython.testing.tools import make_tempfile - import IPython.utils.module_paths as mp TEST_FILE_PATH = Path(__file__).resolve().parent diff --git a/IPython/utils/tests/test_text.py b/IPython/utils/tests/test_text.py index c036f53..cc04cc9 100644 --- a/IPython/utils/tests/test_text.py +++ b/IPython/utils/tests/test_text.py @@ -15,7 +15,6 @@ import os import math import random -import sys from pathlib import Path