Skip to content

style(cosmo): unstringify annotations - #18358

Merged
eerovaher merged 1 commit into
astropy:mainfrom
nstarman:cosmo/typing/future-annotations
Jul 2, 2025
Merged

eerovaher merged 1 commit into
astropy:mainfrom
nstarman:cosmo/typing/future-annotations

Conversation

@nstarman

@nstarman nstarman commented Jun 27, 2025 •

Copy link
Copy Markdown
Member

This PR unstringifies most annotations and makes them parseable at runtime.
This has 2 benefits:

  1. Avoiding some Sphinx shenanigans
  2. Better support for IDEs and runtime type checkers.
  • 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.

@astropy astropy deleted a comment from github-actions Bot Jun 27, 2025
@nstarman
nstarman force-pushed the cosmo/typing/future-annotations branch from e1410a0 to 38e2bd6 Compare June 27, 2025 10:42
@nstarman nstarman moved this from Triage to In Progress in Cosmology, the Expansion Jun 27, 2025
@nstarman
nstarman requested a review from eerovaher June 27, 2025 10:43
Comment thread astropy/cosmology/_src/core.py Resolved
@nstarman
nstarman force-pushed the cosmo/typing/future-annotations branch 4 times, most recently from ff6acc7 to 8d12bf9 Compare June 27, 2025 18:21
@nstarman
nstarman requested a review from eerovaher June 27, 2025 18:35
@nstarman
nstarman force-pushed the cosmo/typing/future-annotations branch from 8d12bf9 to 1f93e78 Compare June 27, 2025 18:37
@nstarman
nstarman marked this pull request as ready for review June 27, 2025 18:58
@nstarman
nstarman requested a review from a team as a code owner June 27, 2025 18:58
@nstarman
nstarman force-pushed the cosmo/typing/future-annotations branch from 1f93e78 to 01799d4 Compare June 27, 2025 19:00

@eerovaher eerovaher 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.

There is a from __future__ import annotations statement in astropy/cosmology/units.py you've missed.

Comment thread astropy/cosmology/_src/core.py Resolved
@nstarman
nstarman force-pushed the cosmo/typing/future-annotations branch from 01799d4 to 04ce0c7 Compare July 1, 2025 20:23

@eerovaher eerovaher 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.

It is good to avoid stringified annotations wherever possible and the reduced line count is a nice bonus.

@github-project-automation github-project-automation Bot moved this from In Progress to Reviewer approved in Cosmology, the Expansion Jul 2, 2025
@eerovaher eerovaher added the typing related to type annotations label Jul 2, 2025
@eerovaher eerovaher modified the milestones: v7.2.0, v7.1.1 Jul 2, 2025
@eerovaher
eerovaher enabled auto-merge July 2, 2025 16:47
@eerovaher
eerovaher merged commit 7f3ed7c into astropy:main Jul 2, 2025
@github-project-automation github-project-automation Bot moved this from Reviewer approved to Done in Cosmology, the Expansion Jul 2, 2025
@lumberbot-app

lumberbot-app Bot commented Jul 2, 2025

Copy link
Copy Markdown

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v7.1.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 7f3ed7c162efdee5f0669c95cee10c75f9e778ae
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #18358: style(cosmo): unstringify annotations'
  1. Push to a named branch:
git push YOURFORK v7.1.x:auto-backport-of-pr-18358-on-v7.1.x
  1. Create a PR against branch v7.1.x, I would have named this PR:

"Backport PR #18358 on branch v7.1.x (style(cosmo): unstringify annotations)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@pllim

pllim commented Jul 2, 2025

Copy link
Copy Markdown
Member

Anyone willing to do manual backport? If not, please change milestone. Chances of downstream pipelines etc inheriting cosmology doc probably quiet low?

nstarman pushed a commit to nstarman/astropy that referenced this pull request Jul 2, 2025
(cherry picked from commit 7f3ed7c)
Signed-off-by: nstarman <[email protected]>

# Conflicts:
#	astropy/cosmology/units.py
@nstarman
nstarman deleted the cosmo/typing/future-annotations branch July 2, 2025 18:58
@nstarman

nstarman commented Jul 2, 2025

Copy link
Copy Markdown
Member Author

Done in #18383

eerovaher added a commit that referenced this pull request Jul 3, 2025
…v7.1.x

Backport PR #18358 on branch v7.1.x (style(cosmo): unstringify annotations)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants