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..af4bfed 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,11 +902,11 @@ 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, + 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, @@ -915,7 +916,7 @@ class IPythonDirective(Directive): shell = None - seen_docs = set() + seen_docs: Set = set() def get_config_options(self): # contains sphinx configuration variables