diff --git a/IPython/core/completer.py b/IPython/core/completer.py index e3351edc93..4873be6b19 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -1362,9 +1362,9 @@ def filter_prefix_tuple(key): # All checks passed! return True - filtered_key_is_final: Dict[ - Union[str, bytes, int, float], _DictKeyState - ] = defaultdict(lambda: _DictKeyState.BASELINE) + filtered_key_is_final: Dict[Union[str, bytes, int, float], _DictKeyState] = ( + defaultdict(lambda: _DictKeyState.BASELINE) + ) for k in keys: # If at least one of the matches is not final, mark as undetermined. diff --git a/IPython/core/guarded_eval.py b/IPython/core/guarded_eval.py index 39fe853f58..628fe2fbcc 100644 --- a/IPython/core/guarded_eval.py +++ b/IPython/core/guarded_eval.py @@ -44,20 +44,17 @@ @undoc class HasGetItem(Protocol): - def __getitem__(self, key) -> None: - ... + def __getitem__(self, key) -> None: ... @undoc class InstancesHaveGetItem(Protocol): - def __call__(self, *args, **kwargs) -> HasGetItem: - ... + def __call__(self, *args, **kwargs) -> HasGetItem: ... @undoc class HasGetAttr(Protocol): - def __getattr__(self, key) -> None: - ... + def __getattr__(self, key) -> None: ... @undoc @@ -329,9 +326,9 @@ class EvaluationContext(NamedTuple): #: Global namespace globals: dict #: Evaluation policy identifier - evaluation: Literal[ - "forbidden", "minimal", "limited", "unsafe", "dangerous" - ] = "forbidden" + evaluation: Literal["forbidden", "minimal", "limited", "unsafe", "dangerous"] = ( + "forbidden" + ) #: Whether the evaluation of code takes place inside of a subscript. #: Useful for evaluating ``:-1, 'col'`` in ``df[:-1, 'col']``. in_subscript: bool = False diff --git a/IPython/core/inputsplitter.py b/IPython/core/inputsplitter.py index 092f21408a..b20dfb16ca 100644 --- a/IPython/core/inputsplitter.py +++ b/IPython/core/inputsplitter.py @@ -15,6 +15,7 @@ For more details, see the class docstrings below. """ + from __future__ import annotations from warnings import warn diff --git a/IPython/core/tests/test_formatters.py b/IPython/core/tests/test_formatters.py index cd8c83e555..5f8eeda20a 100644 --- a/IPython/core/tests/test_formatters.py +++ b/IPython/core/tests/test_formatters.py @@ -535,8 +535,7 @@ def test_custom_repr_namedtuple_partialmethod(): from functools import partialmethod from typing import NamedTuple - class Foo(NamedTuple): - ... + class Foo(NamedTuple): ... Foo.__repr__ = partialmethod(lambda obj: "Hello World") foo = Foo() diff --git a/IPython/core/tests/test_inputtransformer2.py b/IPython/core/tests/test_inputtransformer2.py index c16de5f807..0f563b7204 100644 --- a/IPython/core/tests/test_inputtransformer2.py +++ b/IPython/core/tests/test_inputtransformer2.py @@ -4,6 +4,7 @@ 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 86367b61ec..8e4a63fc96 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 6058ee5a9a..87b716582a 100644 --- a/IPython/external/qt_loaders.py +++ b/IPython/external/qt_loaders.py @@ -8,6 +8,7 @@ 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 1d691a7ea6..e0bf80b075 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/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index af4bfed5a9..5561ad63b8 100644 --- a/IPython/sphinxext/ipython_directive.py +++ b/IPython/sphinxext/ipython_directive.py @@ -904,15 +904,16 @@ class IPythonDirective(Directive): has_content: bool = True required_arguments: int = 0 - optional_arguments: int = 4 # python, suppress, verbatim, doctest + 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 - } + 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 diff --git a/IPython/terminal/interactiveshell.py b/IPython/terminal/interactiveshell.py index 40e2c9a669..416bdab79a 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -586,12 +586,14 @@ def _merge_shortcuts(self, user_shortcuts): RuntimeBinding( command, keys=new_keys or old_keys, - filter=filter_from_string(new_filter) - if new_filter is not None - else ( - old_filter - if old_filter is not None - else filter_from_string("always") + filter=( + filter_from_string(new_filter) + if new_filter is not None + else ( + old_filter + if old_filter is not None + else filter_from_string("always") + ) ), ) ) diff --git a/IPython/terminal/shortcuts/auto_match.py b/IPython/terminal/shortcuts/auto_match.py index 6c2b1ef70c..6095558bbf 100644 --- a/IPython/terminal/shortcuts/auto_match.py +++ b/IPython/terminal/shortcuts/auto_match.py @@ -4,6 +4,7 @@ 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