Skip to content

allow NotImplementedError in formatters - #4832

Merged
takluyver merged 3 commits into
ipython:masterfrom
minrk:formatter-not-implemented
Jan 24, 2014
Merged

takluyver merged 3 commits into
ipython:masterfrom
minrk:formatter-not-implemented

Conversation

@minrk

@minrk minrk commented Jan 20, 2014

Copy link
Copy Markdown
Member

without warning

also make the warnings regular Python warnings, so they can be suppressed.

closes #4792

@Carreau

Carreau commented Jan 20, 2014

Copy link
Copy Markdown
Member

Make sens. Would you like to add handeling for returning NotImplemented ?

adds FormatterWarning warning class, available for suppression
@minrk

minrk commented Jan 20, 2014

Copy link
Copy Markdown
Member Author

Would you like to add handling for returning NotImplemented?

No, returning NotImplemented is only for overriding comparison methods, not for general use.

@Carreau

Carreau commented Jan 20, 2014

Copy link
Copy Markdown
Member

No, returning NotImplemented is only for overriding comparison methods, not for general use.

Ok. I could argue that Python does not have "rich representation" and that the Python doc use the term "rich comparaison" (sic).

@jasongrout

Copy link
Copy Markdown
Member

@minrk: I'm curious: what sources suggest that NotImplemented is not for general use, especially in situations like rich comparison, when you want to signal that the system should try some other ways to accomplish a result?

@minrk

minrk commented Jan 20, 2014

Copy link
Copy Markdown
Member Author

@Carreau It is a similar case, sure. But we do not handle it in the way Python comparison handles NotImplemented, which is to proceed with dispatch as if that entry didn't exist.

@jasongrout Python docs. It doesn't say it's specifically to be avoided elsewhere, but it does describe the case for which it exists, and I have not seen it used for anything else.

@minrk

minrk commented Jan 20, 2014

Copy link
Copy Markdown
Member Author

@jasongrout I don't feel strongly, it just seems like a sufficiently rare pattern that we should only handle the more common one. If the NotImplemented singleton is more common outside of comparison methods than I thought, I have no problem using it.

@Carreau

Carreau commented Jan 20, 2014

Copy link
Copy Markdown
Member

I'm fine with not handeling NotImplemented, we can put that on dev meeting agenda.

@jasongrout

Copy link
Copy Markdown
Member

I don't feel strongly about it either, but I do feel like handling NotImplemented is a nice solution in the discussion on _ipython_display_ and the _repr_* framework.

@takluyver

Copy link
Copy Markdown
Member

I don't feel strongly about which we use, but I do think we should use just one of NotImplemented or NotImplementedError - allowing both just makes the API more confusing.

@minrk

minrk commented Jan 21, 2014

Copy link
Copy Markdown
Member Author

I'm coming around to NotImplemented in terms of basic design, which @jasongrout prefers, but there's one point where NotImplementedError has a big advantage: it's backward-compatible. Returning NotImplemented will raise a TypeError in IPython json serialization, whereas raising NotImplementedError will have the same behavior in 1.0 and 2.0. For that alone, if we pick just one, I think it should be NotImplementedError, even if it is the less elegant.

@ghost ghost assigned ellisonbg Jan 23, 2014
@takluyver

Copy link
Copy Markdown
Member

We discussed NotImplemented vs NotImplementedError in the dev meeting yesterday, and agreed to stick with NotImplementedError for the reason Min gives above.

@minrk, is there anything else you want to do before we merge this?

@minrk

minrk commented Jan 24, 2014

Copy link
Copy Markdown
Member Author

Nope, it should be all set.

takluyver added a commit that referenced this pull request Jan 24, 2014
allow NotImplementedError in formatters
@takluyver
takluyver merged commit b823a5a into ipython:master Jan 24, 2014
@ghost

ghost commented Jan 27, 2014

Copy link
Copy Markdown

I'm noticing that executing a cell that raises such an error pops up a Formatter warning on first execution
but repeated execution of the same cell or the same code in a new cell does not produce a warning.

Is that intentional?

@minrk
minrk deleted the formatter-not-implemented branch March 31, 2014 23:36
mattvonrocketstein pushed a commit to mattvonrocketstein/ipython that referenced this pull request Nov 3, 2014
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.

repr_html exception warning on qtconsole with pandas #4745

5 participants