##// END OF EJS Templates
Merge pull request #12017 from Carreau/cast_cleanup_II...
Matthias Bussonnier -
r25340:88a02754 merge
parent child Browse files
Show More
@@ -22,7 +22,7 b' import os'
22 22 from textwrap import dedent
23 23 import types
24 24 import io as stdlib_io
25 from itertools import zip_longest
25
26 26 from typing import Union
27 27
28 28 # IPython's own
@@ -83,7 +83,7 b" info_fields = ['type_name', 'base_class', 'string_form', 'namespace',"
83 83
84 84 def object_info(**kw):
85 85 """Make an object info dict with all fields present."""
86 infodict = dict(zip_longest(info_fields, [None]))
86 infodict = {k:None for k in info_fields}
87 87 infodict.update(kw)
88 88 return infodict
89 89
@@ -512,7 +512,8 b' class Inspector(Colorable):'
512 512 # 0-offset, so we must adjust.
513 513 page.page(self.format(openpy.read_py_file(ofile, skip_encoding_cookie=False)), lineno - 1)
514 514
515 def _mime_format(self, text, formatter=None):
515
516 def _mime_format(self, text:str, formatter=None) -> dict:
516 517 """Return a mime bundle representation of the input text.
517 518
518 519 - if `formatter` is None, the returned mime bundle has
@@ -528,7 +529,6 b' class Inspector(Colorable):'
528 529 Formatters returning strings are supported but this behavior is deprecated.
529 530
530 531 """
531 text = cast_unicode(text)
532 532 defaults = {
533 533 'text/plain': text,
534 534 'text/html': '<pre>' + text + '</pre>'
@@ -591,7 +591,7 b' class Inspector(Colorable):'
591 591 'text/html': '',
592 592 }
593 593
594 def append_field(bundle, title, key, formatter=None):
594 def append_field(bundle, title:str, key:str, formatter=None):
595 595 field = info[key]
596 596 if field is not None:
597 597 formatted_field = self._mime_format(field, formatter)
@@ -711,7 +711,8 b' class Inspector(Colorable):'
711 711 Returns
712 712 =======
713 713
714 An object info dict with known fields from `info_fields`.
714 An object info dict with known fields from `info_fields`. Keys are
715 strings, values are string or None.
715 716 """
716 717
717 718 if info is None:
General Comments 0
You need to be logged in to leave comments. Login now