Repository navigation
feat(coords): deprecate .get_name() for .name - #17503
Conversation
Signed-off-by: nstarman <[email protected]>
|
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 |
mhvk
left a comment
There was a problem hiding this comment.
I think this is better than .get_name(), but wonder whether it isn't more logical to just set the name (following the same string editing) in __init_subclass__ - as is done for frames. That has the advantage that someone can define the name on the class itself (which is what is required for time format registration).
|
|
Signed-off-by: nstarman <[email protected]>
Signed-off-by: nstarman <[email protected]>
|
@mhvk my only concern with |
This is true for coordinate frames and time formats too. I don't think we have to try to protect against changing attributes. |
Signed-off-by: nstarman <[email protected]>
mhvk
left a comment
There was a problem hiding this comment.
I like this better! Some more detailed comments in-line. Also, do check the API policy for the milestone (think deprecation in a minor version is OK, but not sure).
Signed-off-by: nstarman <[email protected]>
35b704f to
f6ad062
Compare
| ) | ||
| if not hasattr(cls, "name"): | ||
| cls.name = default_name | ||
| elif BaseRepresentationOrDifferential not in cls.__bases__ and cls.name in ( |
There was a problem hiding this comment.
Looking at this again, I'm actually not sure why this first part is in here - just because it doesn't have .name itself? But then wouldn't that be caught? I.e., why not just have,
# Set default name if no name was given or we inherited it
if (name := getattr(cls, "name", None)) is None or name in (getattr(base, "name", None) for base in cls.__bases__):
cls.name = cls.__name__.lower()...
Actually, can we not just do if "name" not in cls.__dict__?
Signed-off-by: nstarman <[email protected]>
acf1d9c to
eea93f1
Compare
mhvk
left a comment
There was a problem hiding this comment.
OK, looks all good now. I looked at https://github.com/astropy/astropy-APEs/blob/main/APE21.rst and it seems clear this can go in 7.1.
Using
classpropertywe can simplify.get_name()to just.name.I'll add changelog, etc if you LMK what you think about the change in general.