diff --git a/IPython/core/completer.py b/IPython/core/completer.py index e3351ed..4873be6 100644 --- a/IPython/core/completer.py +++ b/IPython/core/completer.py @@ -1362,9 +1362,9 @@ def match_dict_keys( # 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 39fe853..628fe2f 100644 --- a/IPython/core/guarded_eval.py +++ b/IPython/core/guarded_eval.py @@ -44,20 +44,17 @@ else: @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 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_formatters.py b/IPython/core/tests/test_formatters.py index cd8c83e..5f8eeda 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 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/ipython_directive.py b/IPython/sphinxext/ipython_directive.py index af4bfed..5561ad6 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 40e2c9a..416bdab 100644 --- a/IPython/terminal/interactiveshell.py +++ b/IPython/terminal/interactiveshell.py @@ -586,12 +586,14 @@ class TerminalInteractiveShell(InteractiveShell): 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 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