Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deprecation attr #15310

Merged
merged 4 commits into from Sep 21, 2023
Merged

deprecation attr #15310

merged 4 commits into from Sep 21, 2023

Conversation

nstarman
Copy link
Member

@nstarman nstarman commented Sep 12, 2023

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
Copy link

github-actions bot commented Sep 12, 2023

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

👋 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
Copy link
Member

@pllim pllim left a comment

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
Copy link
Member Author

nstarman commented Sep 12, 2023

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
Copy link
Member

pllim commented Sep 12, 2023

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
Copy link
Member Author

nstarman commented Sep 12, 2023

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 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
Copy link
Member

@pllim pllim left a comment

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.

Copy link
Contributor

@mhvk mhvk left a comment

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
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
Copy link
Member

pllim commented Sep 21, 2023

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

Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
Signed-off-by: nstarman <nstarman@users.noreply.github.com>
@mhvk
Copy link
Contributor

mhvk commented Sep 21, 2023

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!

Copy link
Contributor

@mhvk mhvk left a comment

Choose a reason for hiding this comment

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

Looks good!

Copy link
Member

@pllim pllim left a comment

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
27 checks passed
@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.

None yet

3 participants