Skip to content

Support for PEP 604 (Allow writing union types as X | Y) with "<type> | None" as Optional #256

@xlorepdarkhelm

Description

@xlorepdarkhelm

PEP 604, which was implemented in Python 3.10, allows for unions to be specified through using the pipe (union) operator. As the Optional[<type>] type already is essentially a shortcut for Union[<type>,None], the new implementation also means that Union[<type>, None] is able to be written as <type> | None. This confuses desert right now and it fails to be able to make a schema.

The current work-around is to still use the Optional[<type>] syntax, which involves importing Optional from typing. It would be nice if desert was more flexible for this.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions