mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-36401: Have help() show readonly properties separately (GH-12517)
This commit is contained in:
parent
113d735e20
commit
62be33870e
3 changed files with 9 additions and 1 deletions
|
@ -203,6 +203,8 @@ def classify_class_attrs(object):
|
|||
for (name, kind, cls, value) in inspect.classify_class_attrs(object):
|
||||
if inspect.isdatadescriptor(value):
|
||||
kind = 'data descriptor'
|
||||
if isinstance(value, property) and value.fset is None:
|
||||
kind = 'readonly property'
|
||||
results.append((name, kind, cls, value))
|
||||
return results
|
||||
|
||||
|
@ -884,6 +886,8 @@ class HTMLDoc(Doc):
|
|||
lambda t: t[1] == 'class method')
|
||||
attrs = spill('Static methods %s' % tag, attrs,
|
||||
lambda t: t[1] == 'static method')
|
||||
attrs = spilldescriptors("Readonly properties %s:\n" % tag, attrs,
|
||||
lambda t: t[1] == 'readonly property')
|
||||
attrs = spilldescriptors('Data descriptors %s' % tag, attrs,
|
||||
lambda t: t[1] == 'data descriptor')
|
||||
attrs = spilldata('Data and other attributes %s' % tag, attrs,
|
||||
|
@ -1341,6 +1345,8 @@ location listed above.
|
|||
lambda t: t[1] == 'class method')
|
||||
attrs = spill("Static methods %s:\n" % tag, attrs,
|
||||
lambda t: t[1] == 'static method')
|
||||
attrs = spilldescriptors("Readonly properties %s:\n" % tag, attrs,
|
||||
lambda t: t[1] == 'readonly property')
|
||||
attrs = spilldescriptors("Data descriptors %s:\n" % tag, attrs,
|
||||
lambda t: t[1] == 'data descriptor')
|
||||
attrs = spilldata("Data and other attributes %s:\n" % tag, attrs,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue