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

Support extending the refinement types with more annotations #1

Open
espetro opened this issue Sep 26, 2021 · 0 comments
Open

Support extending the refinement types with more annotations #1

espetro opened this issue Sep 26, 2021 · 0 comments

Comments

@espetro
Copy link
Owner

espetro commented Sep 26, 2021

Currently, refinement type annotations do not support additional annotations, e.g. annotating a non-empty list with a ValueRange:

from refined import NonEmpty
from some_module import ValueRange
from typing import List

not_valid = NonEmpty[List[str], ValueRange(0, 10)]
not_valid_neither = NonEmpty[List[str]](extra_annotations=[ValueRange(0, 10)])

However, as explained in the PEP 593, Nested Annotated types are flattened, with metadata ordered starting with the innermost annotation:

from refined import NonEmpty
from some_module import ValueRange
from typing import List

valid = Annotated[NonEmpty[List[str]], ValueRange(0, 10)]

So it should be also OK if we do not support this.

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

1 participant