Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG: Fix pretty-printing for overzealous objects #1495

Merged
merged 1 commit into from Mar 16, 2012

Conversation

rkern
Copy link
Contributor

@rkern rkern commented Mar 15, 2012

Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.

…ething non-callable for any requested attribute (thus confusing hasattr).
@minrk
Copy link
Member

minrk commented Mar 15, 2012

Looks clean and sensible to me. Can you name a few libraries that do this sort of thing? Perhaps Pyro, etc. Maybe we can run some extra tests if some of these libraries are present.

@rkern
Copy link
Contributor Author

rkern commented Mar 15, 2012

http://pypi.python.org/pypi/underverse is the one I was using when I ran into the problem.

@minrk
Copy link
Member

minrk commented Mar 16, 2012

We've also had completion issues with these libraries. It would be useful to give a few tests so that future changes will be caught. But for now, I think this can just be merged, unless you want to write a simple test with underverse now.

@rkern
Copy link
Contributor Author

rkern commented Mar 16, 2012

I added a test with a badly-formed _repr_pretty_ attribute. I could write one with a __getattr__ that returns a generator for greater verisimilitude, but I'm not sure what else that would catch that the current test doesn't.

minrk added a commit that referenced this pull request Mar 16, 2012
BUG: Fix pretty-printing for overzealous objects

Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.
@minrk minrk merged commit 873e364 into ipython:master Mar 16, 2012
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
BUG: Fix pretty-printing for overzealous objects

Some classes use __getattr__ to automatically create requested attributes. The recent trend of LINQ-like query objects is what I ran into. This confuses the pretty-printing machinery that tests for _repr_pretty_. This pull request fixes many of these problems by simply testing if the _repr_pretty_ attribute is callable. This may still be confused by certain mocking frameworks, but it's a good start.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants