mirror of
https://github.com/python/cpython.git
synced 2025-08-22 09:45:06 +00:00
bpo-44712: Replace "type(literal)" with corresponding builtin types (GH-27294)
I suppose it is a remnants of very old code written when str, int, list, dict, etc were functions and not classes.
This commit is contained in:
parent
c826867b7c
commit
3680ebed7f
19 changed files with 41 additions and 39 deletions
12
Lib/pydoc.py
12
Lib/pydoc.py
|
@ -727,7 +727,7 @@ class HTMLDoc(Doc):
|
|||
"""Produce HTML for a class tree as given by inspect.getclasstree()."""
|
||||
result = ''
|
||||
for entry in tree:
|
||||
if type(entry) is type(()):
|
||||
if isinstance(entry, tuple):
|
||||
c, bases = entry
|
||||
result = result + '<dt class="heading-text">'
|
||||
result = result + self.classlink(c, modname)
|
||||
|
@ -737,7 +737,7 @@ class HTMLDoc(Doc):
|
|||
parents.append(self.classlink(base, modname))
|
||||
result = result + '(' + ', '.join(parents) + ')'
|
||||
result = result + '\n</dt>'
|
||||
elif type(entry) is type([]):
|
||||
elif isinstance(entry, list):
|
||||
result = result + '<dd>\n%s</dd>\n' % self.formattree(
|
||||
entry, modname, c)
|
||||
return '<dl>\n%s</dl>\n' % result
|
||||
|
@ -1190,14 +1190,14 @@ class TextDoc(Doc):
|
|||
"""Render in text a class tree as returned by inspect.getclasstree()."""
|
||||
result = ''
|
||||
for entry in tree:
|
||||
if type(entry) is type(()):
|
||||
if isinstance(entry, tuple):
|
||||
c, bases = entry
|
||||
result = result + prefix + classname(c, modname)
|
||||
if bases and bases != (parent,):
|
||||
parents = (classname(c, modname) for c in bases)
|
||||
result = result + '(%s)' % ', '.join(parents)
|
||||
result = result + '\n'
|
||||
elif type(entry) is type([]):
|
||||
elif isinstance(entry, list):
|
||||
result = result + self.formattree(
|
||||
entry, modname, c, prefix + ' ')
|
||||
return result
|
||||
|
@ -2044,7 +2044,7 @@ has the same effect as typing a particular string at the help> prompt.
|
|||
return self.input.readline()
|
||||
|
||||
def help(self, request):
|
||||
if type(request) is type(''):
|
||||
if isinstance(request, str):
|
||||
request = request.strip()
|
||||
if request == 'keywords': self.listkeywords()
|
||||
elif request == 'symbols': self.listsymbols()
|
||||
|
@ -2129,7 +2129,7 @@ module "pydoc_data.topics" could not be found.
|
|||
if not target:
|
||||
self.output.write('no documentation found for %s\n' % repr(topic))
|
||||
return
|
||||
if type(target) is type(''):
|
||||
if isinstance(target, str):
|
||||
return self.showtopic(target, more_xrefs)
|
||||
|
||||
label, xrefs = target
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue