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

Chained constraints #31

Closed
adriangb opened this issue Nov 15, 2022 · 2 comments
Closed

Chained constraints #31

adriangb opened this issue Nov 15, 2022 · 2 comments

Comments

@adriangb
Copy link
Contributor

Thought from #28: we could also do something like Exponent = Annotated[int, Gt(0) & MultipleOf(2)].

Implementing & would be easy: it just creates a GroupedMetadata.

Other operators would be trickier: Annotated[str, Foo | Bar] should actually be expressed as Annotated[str, Bar] | Annotated[str, Foo], and I have no idea what XOR would be, I think we’d have to offload that to implementers. So I think this idea has short legs.

@adriangb
Copy link
Contributor Author

Also as “pretty” as & seems, it’s not saving any typing.

@Zac-HD
Copy link
Member

Zac-HD commented Nov 15, 2022

Yeah, & can just be spelled ,; I agree that | should be expressed outside the Annotated[], and I don't think that xor is even expressible in Python types at the moment (without high-grade magic, anyway).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants