DEP: bump minimal supported IPython version to 7.32, declare ipykernel and ipywidgets as optional deps, cleanup#16354
Conversation
|
Thank you for your contribution to Astropy! 🌌 This checklist is meant to remind the package maintainers who will review this pull request of some common things to look for.
|
|
👋 Thank you for your draft pull request! Do you know that you can use |
|
|
||
| try: | ||
| if HAS_IPYTHON: | ||
| from ipykernel.iostream import OutStream |
There was a problem hiding this comment.
IPython.zmq was removed in 2013 in ipython/ipython#4121 and this functionality was moved to IPython.kernel, which was itself deprecated in IPython 4.0.0 and removed in 8.0.0, see ipython/ipython#13386
79c297b to
8b6918d
Compare
8b6918d to
81ddc4d
Compare
81ddc4d to
2126ef2
Compare
2126ef2 to
3ef8d9b
Compare
| cls._OutStream = None | ||
| try: | ||
| cls.get_ipython() | ||
| except NameError: |
There was a problem hiding this comment.
I don't know what this NameError was for but looks like handling it has been dropped in this PR. Can you please clarify? Thanks!
There was a problem hiding this comment.
The get_ipython method was oddly written in such a way that its return variable was only bound if IPython was installed, meaning it was effectively relying on a NameError being raised otherwise. Since I also rewrote the method in a more conventional manner, this handling isn't needed any more
There was a problem hiding this comment.
Still, looking at code in main, the original design looks like it never intended to throw exception if IPython is not installed, but this PR does. Can we refactor in a way that does not throw exception? Thanks for your patience!
There was a problem hiding this comment.
I'm confused
original design looks like it never intended to throw exception if IPython is not installed
if you mean the get_ipython class method, it seems to me that it was actually designed to throw an exception since that's how it's been used through except NameError (albeit a quirky exception to catch in your own code).
but this PR does
I don't understand, where else would an exception be raised in my version ?
There was a problem hiding this comment.
Actually the NameError on main makes no sense to me. When I try to emulate the implementation, I get UnboundLocalError. But that is neither here nor there...
The point I was trying to make is that get_ipython on main defers the exception handling to OutStream. But in this PR, you explicitly throws ModuleNotFoundError from within get_ipython if IPython is not installed. I think that is a subtle behavior change?
There was a problem hiding this comment.
actually it was easy enough that I just went for it: #16369
There was a problem hiding this comment.
Also, I figured that this _IPython.get_ipython method was not actually needed, so I refactored it. To make it easier for you to follow after I rebased, I've kept this one change as a separate commit (that should eventually get squashed).
There was a problem hiding this comment.
Thanks, does look much cleaner now. But I still don't know what is the point of this whole _IPython class now that I dig into the code. I can't seem to see it being used anywhere and it is "hidden".
Anyways, should we get #16369 in first?
There was a problem hiding this comment.
Ah nvm, found it. Just used internally here for isatty.
There was a problem hiding this comment.
should we get #16369 in first?
these PRs are actually completely independent as it turns out; they can be merged in any order
…l and ipywidgets as optional deps, cleanup
…pykernel as optional dep, cleanup
3ef8d9b to
677a81a
Compare
…l and ipywidgets as optional deps, cleanup (#16354) * DEP: bump minimal supported IPython version to 7.32, declare ipykernel and ipywidgets as optional deps, cleanup * fixup! DEP: bump minimal supported IPython version to 7.32, declare ipykernel as optional dep, cleanup
Description
In the same vein as #16353, but specifically for IPython since this one requires a "bump" (effectively I'm just declaring as minimal the first version that supports Python 3.10, which is still a little bit shy of SPEC 0's current recommendation at 7.39).