Skip to content

feature request: record: return with strong typing #20

@cachho

Description

@cachho

Is your feature request related to a problem? Please describe.
In zod, when I validate an object or record, the returned value of the parse operation is strongly typed, with all the keys and types specified in the schema.

Describe the solution you'd like
I'd like record (and list) types to annotate the type that's the result of the validation, based on the schema.

At the moment it just shows the input type, so e.g. zon.element_list(zon.string()).validate([0]) should show list[str], but it actually shows list[int] right now. Obiously, the validation will either fail or return a list of strings.

Describe alternatives you've considered
I'm not sure if this is possible in python like that.

Additional context
I'm talking about this specifically in the context of type hints in vscode.
I'm kind of new to statically typed python, so not sure if this has to do with the extensions I installed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions