Skip to content

deprecation attr - #15310

Merged
pllim merged 4 commits into
astropy:mainfrom
nstarman:utils-deprecation-attr
Sep 21, 2023
Merged

pllim merged 4 commits into
astropy:mainfrom
nstarman:utils-deprecation-attr

Conversation

@nstarman

@nstarman nstarman commented Sep 12, 2023 •

Copy link
Copy Markdown
Member

Adds the __deprecated__ attribute.
Also cleans up deprecated so that we don't re-define the helper functions every time deprecated is called.
deprecated still redefines all functions on every call.

@nstarman nstarman added this to the v6.0 milestone Sep 12, 2023
@github-actions github-actions Bot added the utils label Sep 12, 2023
@github-actions

github-actions Bot commented Sep 12, 2023 •

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?
  • Is a milestone set? Milestone must be set but we cannot check for it on Actions; do not let the green checkmark fool you.
  • 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.

@github-actions

Copy link
Copy Markdown
Contributor

👋 Thank you for your draft pull request! Do you know that you can use [ci skip] or [skip ci] in your commit messages to skip running continuous integration tests until you are ready?

@nstarman
nstarman requested a review from mhvk September 12, 2023 14:21

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

I didn't expect to see so much diff. I thought it would be a few lines to add a new attribute.

@nstarman

nstarman commented Sep 12, 2023 •

Copy link
Copy Markdown
Member Author

If you look at 12b5d46, then it's only a few lines.
I just took the opportunity to also clean up the code. Basically I just moved a pile of functions defined inside deprecated out. They were unnecessarily being re-defined every time deprecated was called.

@pllim

pllim commented Sep 12, 2023

Copy link
Copy Markdown
Member

Can we separate the two into different PRs? 🙏

Also I don't think refactoring is necessary given that you already want to replace with yet another implementation down the road.

@nstarman

nstarman commented Sep 12, 2023 •

Copy link
Copy Markdown
Member Author

Can we separate the two into different PRs? 🙏

Sure.

Also I don't think refactoring is necessary given that you already want to replace with yet another implementation down the road.

This code cleanup / improvement is cherry picked from #15301, which then just changes some more internals to use typing.deprecated.

@nstarman
nstarman force-pushed the utils-deprecation-attr branch from 80b00bb to 4f8c9fd Compare September 12, 2023 14:39
@nstarman
nstarman requested a review from pllim September 12, 2023 15:01
@nstarman
nstarman marked this pull request as ready for review September 12, 2023 15:02

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

Much cleaner, thanks! I'll let mhvk review since he requested it.

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yes, this looks good! Should there be some test, though? E.g., I think it works on attributes indirectly, maybe worthwhile to test? I guess more generally: does it in fact work in your IDE?

@nstarman

Copy link
Copy Markdown
Member Author

Unfortunately since VSCode's code help is generally powered by static analysis our decorator is not recognized.

Screenshots
CleanShot 2023-09-21 at 09 55 30@2x CleanShot 2023-09-21 at 09 56 19@2x

Note that VSCode has crossed-out the function as I type it

At least _deprecated__ is attached correctly (see the tests)

@pllim

pllim commented Sep 21, 2023

Copy link
Copy Markdown
Member

I think you need to rebase to pick up RTD fix.

Signed-off-by: nstarman <[email protected]>
Signed-off-by: nstarman <[email protected]>
Signed-off-by: nstarman <[email protected]>
@nstarman
nstarman force-pushed the utils-deprecation-attr branch from 5f3b51f to 267112e Compare September 21, 2023 14:17
@nstarman
nstarman requested a review from mhvk September 21, 2023 14:22
@mhvk

mhvk commented Sep 21, 2023

Copy link
Copy Markdown
Contributor

It might be worth suggesting to VSCode to assume that anything marked by *deprecated* is actually deprecated... Doesn't seem like there would be many false positives!

@mhvk mhvk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Looks good!

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

Thanks!

@pllim
pllim enabled auto-merge (squash) September 21, 2023 14:37
@pllim
pllim merged commit c085b96 into astropy:main Sep 21, 2023
@nstarman
nstarman deleted the utils-deprecation-attr branch September 21, 2023 15:04
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