Skip to content

Commit

Permalink
FIX: Typing annotations
Browse files Browse the repository at this point in the history
Running `mypy -p IPython.sphinxext` raised a few errors. Fix them and
strip some trailing whitespace from a few places.
  • Loading branch information
farisachugthai authored and Carreau committed Oct 27, 2024
1 parent 6aa7cdc commit c8d9469
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion IPython/sphinxext/custom_doctests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions IPython/sphinxext/ipython_directive.py
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@

# Authors
# =======
#
#
# - John D Hunter: original author.
# - Fernando Perez: refactoring, documentation, cleanups, port to 0.11.
# - VáclavŠmilauer <eudoxos-AT-arcig.cz>: Prompt generalizations.
Expand All @@ -196,6 +196,7 @@
import warnings
import shutil
from io import StringIO
from typing import Any, Dict, Set

# Third-party
from docutils.parsers.rst import directives
Expand Down Expand Up @@ -425,7 +426,7 @@ def process_image(self, decorator):
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)
Expand Down Expand Up @@ -901,11 +902,11 @@ def custom_doctest(self, decorator, input_lines, found, submitted):

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,
Expand All @@ -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
Expand Down

0 comments on commit c8d9469

Please sign in to comment.