Skip to content

Remove astropy.utils.console._IPython - #18153

Merged
pllim merged 1 commit into
astropy:mainfrom
eerovaher:rm_IPython
Mar 27, 2026
Merged

pllim merged 1 commit into
astropy:mainfrom
eerovaher:rm_IPython

Conversation

@eerovaher

Copy link
Copy Markdown
Member

Description

The class is used in only a couple of places that are simple enough to rewrite.

  • By checking this box, the PR author has requested that maintainers do NOT use the "Squash and Merge" button. Maintainers should respect this when possible; however, the final decision is at the discretion of the maintainer that merges the PR.

@github-actions

Copy link
Copy Markdown
Contributor

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.

  • Do the proposed changes actually accomplish desired goals?
  • Do the proposed changes follow the Astropy coding guidelines?
  • Are tests added/updated as required? If so, do they follow the Astropy testing guidelines?
  • Are docs added/updated as required? If so, do they follow the Astropy documentation guidelines?
  • Is rebase and/or squash necessary? If so, please provide the author with appropriate instructions. Also see instructions for rebase and squash.
  • Did the CI pass? If no, are the failures related? If you need to run daily and weekly cron jobs as part of the PR, please apply the "Extra CI" label. Codestyle issues can be fixed by the bot.
  • Is a change log needed? If yes, did the change log check pass? If no, add the "no-changelog-entry-needed" label. If this is a manual backport, use the "skip-changelog-checks" label unless special changelog handling is necessary.
  • Is this a big PR that makes a "What's new?" entry worthwhile and if so, is (1) a "what's new" entry included in this PR and (2) the "whatsnew-needed" label applied?
  • At the time of adding the milestone, if the milestone set requires a backport to release branch(es), apply the appropriate "backport-X.Y.x" label(s) before merge.

Comment thread astropy/utils/console.py
return cls._OutStream

@classproperty
def ipyio(cls):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is not used anywhere.

Comment thread astropy/utils/console.py
if hasattr(file, "isatty"):
return file.isatty()

if _IPython.OutStream is None or (not isinstance(file, _IPython.OutStream)):

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If ipykernel is not available then _IPython.OutStream is None.

If ipykernel is available then _IPython.OutStream is ipykernel.iostream.OutStream, which does have a isatty() method (see the documentation for current stable ipykernel (v6.29) or the source code for v6.16, which is the oldest version astropy supports). Therefore, if file is an _IPython.OutStream instance then it would have been handled by the if hasattr(file, "isatty") block earlier.

Either way, the expression in this if-statement is true, so if code execution ever reaches this point we are guaranteed to return False and the getattr() call below is never performed.

@pllim

pllim commented May 15, 2025

Copy link
Copy Markdown
Member

I didn't write these originally so I don't know the original motivation or how to effectively test that this refactoring didn't accidentally break some IPython use cases. @astrofrog you remember?

@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Oct 25, 2025
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@eerovaher eerovaher removed the Close? Tell stale bot that this issue/PR is stale label Oct 27, 2025
@pllim

pllim commented Oct 28, 2025

Copy link
Copy Markdown
Member

Can we defer this for v8.0? So if it does somehow break downstream, it wouldn't be right before a release candidate?

@eerovaher

Copy link
Copy Markdown
Member Author

I don't agree that this PR was opened so late that it shouldn't be merged.

@pllim

pllim commented Oct 29, 2025

Copy link
Copy Markdown
Member

I was hoping other devs would chime in and then I forgot about it until now, sorry!

@astrofrog astrofrog modified the milestones: v7.2.0, v9.0.0, v8.0.0 Nov 3, 2025
@github-actions github-actions Bot added the Close? Tell stale bot that this issue/PR is stale label Mar 27, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Hi humans 👋 - this pull request hasn't had any new commits for approximately 4 months. I plan to close this in 30 days if the pull request doesn't have any new commits by then.

In lieu of a stalled pull request, please consider closing this and open an issue instead if a reminder is needed to revisit in the future. Maintainers may also choose to add keep-open label to keep this PR open but it is discouraged unless absolutely necessary.

If this PR still needs to be reviewed, as an author, you can rebase it to reset the clock.

If you believe I commented on this pull request incorrectly, please report this here.

@pllim pllim removed the Close? Tell stale bot that this issue/PR is stale label Mar 27, 2026

@pllim pllim left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No other devs objected and we're in v8 dev cycle now, so let's merge and see... 🤞

Thanks!

@pllim pllim added the Extra CI Run cron CI as part of PR label Mar 27, 2026
@pllim
pllim merged commit 6962e1b into astropy:main Mar 27, 2026
51 of 52 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants