summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-05-08 14:10:11 (GMT)
committerGitHub <noreply@github.com>2022-05-08 14:10:11 (GMT)
commit3680ebed7f3e529d01996dd0318601f9f0d02b4b (patch)
tree7889885b7ce3089f5ce5d02d88e7a55518644aae /Lib/pydoc.py
parentc826867b7c1bb69639290d8df0f850ec3f9a6c72 (diff)
downloadcpython-3680ebed7f3e529d01996dd0318601f9f0d02b4b.zip
cpython-3680ebed7f3e529d01996dd0318601f9f0d02b4b.tar.gz
cpython-3680ebed7f3e529d01996dd0318601f9f0d02b4b.tar.bz2
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.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 297ff96..cec9ac8 100755
--- a/Lib/pydoc.py
+++ b/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