Skip to content

Annotation for defining Pydantic types based on AstroPy's Quantity#58

Closed
hettlage wants to merge 6 commits intoAEONplus:mainfrom
saltastroops:quantity-type
Closed

Annotation for defining Pydantic types based on AstroPy's Quantity#58
hettlage wants to merge 6 commits intoAEONplus:mainfrom
saltastroops:quantity-type

Conversation

@hettlage
Copy link
Copy Markdown
Contributor

This PR addresses issue #55.

It adds a new class AstropyQuantityTypeAnnotation, which lets the user define custom types making use of AstroPy's Quantity class.

Tests for this new class are added, and the documentation on defining models is updated.

@jchate6 jchate6 requested a review from Fingel October 21, 2025 15:43
@Fingel
Copy link
Copy Markdown
Contributor

Fingel commented Oct 21, 2025

Hello again @hettlage ! Thanks for this PR.
It does look like a nice type to have. It doesn't appear to be used anywhere. Is this intentional? For example, in the proper motion field for Targets:

proper_motion_ra: Annotated[float, Le(20000.0)] = 0

@hettlage
Copy link
Copy Markdown
Contributor Author

I'm happy to update the models. This will need some additional validators, as the validators of the annotated_types library don't support Quantity objects. I'll extend the PR accordingly.

The validators are intended for cases where you cannot use the corresponding validators from the `annotated_types` library (for example, when dealing with AstroPy `Quantity` objects).
The validators are intended for cases where you cannot use the corresponding validators from the `annotated_types` library (for example, when dealing with AstroPy `Quantity` objects).
@hettlage
Copy link
Copy Markdown
Contributor Author

I have added some validators.

But on second thoughts, I'm reluctant to update the existing models, as this would be a breaking change - consumers of the models might assume that the affected properties have float values, whereas now in fact they would be Quantity objects.

Would you be happy with such breaking changes?

@hettlage
Copy link
Copy Markdown
Contributor Author

Is there anything else you would need from me for this PR? :-)

@Fingel Fingel mentioned this pull request May 7, 2026
@Fingel
Copy link
Copy Markdown
Contributor

Fingel commented May 7, 2026

Closing this for now as the required functionality was rolled into #64 we can re-open this later for use in other modules if deemed useful.

@Fingel Fingel closed this May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants