Update signature presentation in pinfo classes #5285

Merged
merged 3 commits into from Mar 7, 2014

2 participants

@minrk
IPython member

closes #5103

classes:

  • init definition comes before class docstring
  • remove Constructor info block, because it no longer has multiple entries
  • don't include instance call definition as definition

objects:

  • don't duplicate call def and definition in callables

Before:

In [2]: pinfo C
Type:       type
String Form:<class '__main__.C'>
Definition: C(self, call)
Docstring:  class docstring
Constructor information:
 Definition:C(self, a=5)
 Docstring:     init docstring

In [3]: pinfo c
Type:       C
String Form:<__main__.C object at 0x10ee5e410>
Definition: c(self, call)
Docstring:  class docstring
Constructor docstring:init docstring
Call def:   c(self, call)
Call docstring:call docstring

After:

In [2]: pinfo C
Type:            type
String form:     <class '__main__.C'>
Init definition: C(self, a=5)
Docstring:       class docstring
Init docstring:  init docstring

In [3]: pinfo c
Type:           C
String form:    <__main__.C object at 0x102e23510>
Definition:     c(self, call)
Docstring:      class docstring
Init docstring: init docstring
Call docstring: call docstring
minrk added some commits Mar 6, 2014
@minrk minrk Update signature presentation in pinfo classes
classes:

- init definition comes before class docstring
- remove Constructor info block, because it no longer has multiple entries
- don't include instance call definition as definition

objects:

- don't duplicate call def and definition in callables
bbbaecf
@minrk minrk sentence case
There was a mixture of sentence and title case,
let's be consistent.
7b9a9e1
@takluyver takluyver and 1 other commented on an outdated diff Mar 7, 2014
IPython/core/oinspect.py
"""
out = []
header = self.__head
+ if title_width == 0:
+ for title, _ in fields:
+ title_width = max(len(title) + 2, title_width)
@takluyver
IPython member

I think this is a bit nicer with a genexp:

title_width = max(len(title) + 2 for title, _ in fields)
@minrk
IPython member
minrk added a note Mar 7, 2014

nice, done.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@takluyver
IPython member

Besides that minor point, 👍

@takluyver takluyver merged commit 313df38 into ipython:master Mar 7, 2014

1 check passed

Details default The Travis CI build passed
@minrk minrk deleted the minrk:constructor-definition branch Mar 31, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment