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

wishlist: attrs.validators.instance_of parse nested types (lists and maps) not needing verbose deep_iterable, deep_map and optional #1235

Open
txemi opened this issue Feb 4, 2024 · 0 comments
Labels

Comments

@txemi
Copy link

txemi commented Feb 4, 2024

I wish I could write:

validator=attrs.validators.instance_of(typing.Optional[list[int]])

instead of:

validator=attrs.validators.instance_of(
        attrs.validators.optional(attrs.validators.deep_iterable(int)))

It is easier to read and there is not need to use another differente way to express a type, just the standard python way.

Besides it is an step nearer to autodetect type from standard declaration and no need to tell it again in attr deffinition:

@attrs.define
class Myclass:
    _myattr: typing.Optional[list[int]] = attrs.field()

Thanks

@hynek hynek added the Feature label Apr 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants