diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 092f214..b20dfb1 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -15,6 +15,7 @@ and stores the results. For more details, see the class docstrings below. """ + from __future__ import annotations from warnings import warn diff --git a/IPython/core/tests/test_inputtransformer2.py b/IPython/core/tests/test_inputtransformer2.py index c16de5f..0f563b7 100644 --- a/IPython/core/tests/test_inputtransformer2.py +++ b/IPython/core/tests/test_inputtransformer2.py @@ -4,6 +4,7 @@ Line-based transformers are the simpler ones; token-based transformers are more complex. See test_inputtransformer2_line for tests for line-based transformations. """ + import platform import string import sys diff --git a/IPython/core/tests/test_paths.py b/IPython/core/tests/test_paths.py index 86367b6..8e4a63f 100644 --- a/IPython/core/tests/test_paths.py +++ b/IPython/core/tests/test_paths.py @@ -160,14 +160,16 @@ def test_get_ipython_dir_8(): # test only when HOME directory actually writable return - with patch.object(paths, "_writable_dir", lambda path: bool(path)), patch.object( - paths, "get_xdg_dir", return_value=None - ), modified_env( - { - "IPYTHON_DIR": None, - "IPYTHONDIR": None, - "HOME": "/", - } + with ( + patch.object(paths, "_writable_dir", lambda path: bool(path)), + patch.object(paths, "get_xdg_dir", return_value=None), + modified_env( + { + "IPYTHON_DIR": None, + "IPYTHONDIR": None, + "HOME": "/", + } + ), ): assert paths.get_ipython_dir() == "/.ipython" diff --git a/IPython/external/qt_loaders.py b/IPython/external/qt_loaders.py index 6058ee5..87b7165 100644 --- a/IPython/external/qt_loaders.py +++ b/IPython/external/qt_loaders.py @@ -8,6 +8,7 @@ bindings, which is unstable and likely to crash This is used primarily by qt and qt_for_kernel, and shouldn't be accessed directly from the outside """ + import importlib.abc import sys import os diff --git a/IPython/lib/clipboard.py b/IPython/lib/clipboard.py index 1d691a7..e0bf80b 100644 --- a/IPython/lib/clipboard.py +++ b/IPython/lib/clipboard.py @@ -1,5 +1,6 @@ """ Utilities for accessing the platform's clipboard. """ + import os import subprocess diff --git a/IPython/sphinxext/custom_doctests.py b/IPython/sphinxext/custom_doctests.py index 75c2a25..f0ea034 100644 --- a/IPython/sphinxext/custom_doctests.py +++ b/IPython/sphinxext/custom_doctests.py @@ -107,7 +107,7 @@ def float_doctest(sphinx_shell, args, input_lines, found, submitted): try: rtol = float(args[2]) atol = float(args[3]) - except IndexError as e: + except IndexError: e = ("Both `rtol` and `atol` must be specified " "if either are specified: {0}".format(args)) raise IndexError(e) from e diff --git a/IPython/sphinxext/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index 88357a5..5561ad6 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -174,7 +174,7 @@ To Do # Authors # ======= -# +# # - John D Hunter: original author. # - Fernando Perez: refactoring, documentation, cleanups, port to 0.11. # - VáclavŠmilauer : Prompt generalizations. @@ -196,6 +196,7 @@ import ast import warnings import shutil from io import StringIO +from typing import Any, Dict, Set # Third-party from docutils.parsers.rst import directives @@ -425,7 +426,7 @@ class EmbeddedSphinxShell(object): source_dir = self.source_dir saveargs = decorator.split(' ') filename = saveargs[1] - # insert relative path to image file in source + # insert relative path to image file in source # as absolute path for Sphinx # sphinx expects a posix path, even on Windows path = pathlib.Path(savefig_dir, filename) @@ -901,21 +902,22 @@ class EmbeddedSphinxShell(object): class IPythonDirective(Directive): - has_content = True - required_arguments = 0 - optional_arguments = 4 # python, suppress, verbatim, doctest - final_argumuent_whitespace = True - option_spec = { 'python': directives.unchanged, - 'suppress' : directives.flag, - 'verbatim' : directives.flag, - 'doctest' : directives.flag, - 'okexcept': directives.flag, - 'okwarning': directives.flag - } + has_content: bool = True + required_arguments: int = 0 + optional_arguments: int = 4 # python, suppress, verbatim, doctest + final_argumuent_whitespace: bool = True + option_spec: Dict[str, Any] = { + "python": directives.unchanged, + "suppress": directives.flag, + "verbatim": directives.flag, + "doctest": directives.flag, + "okexcept": directives.flag, + "okwarning": directives.flag, + } shell = None - seen_docs = set() + seen_docs: Set = set() def get_config_options(self): # contains sphinx configuration variables diff --git a/IPython/terminal/shortcuts/auto_match.py b/IPython/terminal/shortcuts/auto_match.py index 6c2b1ef..6095558 100644 --- a/IPython/terminal/shortcuts/auto_match.py +++ b/IPython/terminal/shortcuts/auto_match.py @@ -4,6 +4,7 @@ Utilities function for keybinding with prompt toolkit. This will be bound to specific key press and filter modes, like whether we are in edit mode, and whether the completer is open. """ + import re from prompt_toolkit.key_binding import KeyPressEvent