Skip to content

Commit c8d9469

Browse files
farisachugthaiCarreau
authored andcommitted
FIX: Typing annotations
Running `mypy -p IPython.sphinxext` raised a few errors. Fix them and strip some trailing whitespace from a few places.
1 parent 6aa7cdc commit c8d9469

File tree

2 files changed

+10
-9
lines changed

2 files changed

+10
-9
lines changed

IPython/sphinxext/custom_doctests.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@ def float_doctest(sphinx_shell, args, input_lines, found, submitted):
107107
try:
108108
rtol = float(args[2])
109109
atol = float(args[3])
110-
except IndexError as e:
110+
except IndexError:
111111
e = ("Both `rtol` and `atol` must be specified "
112112
"if either are specified: {0}".format(args))
113113
raise IndexError(e) from e

IPython/sphinxext/ipython_directive.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174

175175
# Authors
176176
# =======
177-
#
177+
#
178178
# - John D Hunter: original author.
179179
# - Fernando Perez: refactoring, documentation, cleanups, port to 0.11.
180180
# - VáclavŠmilauer <eudoxos-AT-arcig.cz>: Prompt generalizations.
@@ -196,6 +196,7 @@
196196
import warnings
197197
import shutil
198198
from io import StringIO
199+
from typing import Any, Dict, Set
199200

200201
# Third-party
201202
from docutils.parsers.rst import directives
@@ -425,7 +426,7 @@ def process_image(self, decorator):
425426
source_dir = self.source_dir
426427
saveargs = decorator.split(' ')
427428
filename = saveargs[1]
428-
# insert relative path to image file in source
429+
# insert relative path to image file in source
429430
# as absolute path for Sphinx
430431
# sphinx expects a posix path, even on Windows
431432
path = pathlib.Path(savefig_dir, filename)
@@ -901,11 +902,11 @@ def custom_doctest(self, decorator, input_lines, found, submitted):
901902

902903
class IPythonDirective(Directive):
903904

904-
has_content = True
905-
required_arguments = 0
906-
optional_arguments = 4 # python, suppress, verbatim, doctest
907-
final_argumuent_whitespace = True
908-
option_spec = { 'python': directives.unchanged,
905+
has_content: bool = True
906+
required_arguments: int = 0
907+
optional_arguments: int = 4 # python, suppress, verbatim, doctest
908+
final_argumuent_whitespace: bool = True
909+
option_spec: Dict[str, Any] = { 'python': directives.unchanged,
909910
'suppress' : directives.flag,
910911
'verbatim' : directives.flag,
911912
'doctest' : directives.flag,
@@ -915,7 +916,7 @@ class IPythonDirective(Directive):
915916

916917
shell = None
917918

918-
seen_docs = set()
919+
seen_docs: Set = set()
919920

920921
def get_config_options(self):
921922
# contains sphinx configuration variables

0 commit comments

Comments
 (0)