Skip to content

Support Unions #3

Open
Open

Description

@neighthan

Just try each type in the Union until one of them works; re-raise the last exception if none do. Make a factory for this which takes in a Union annotation and returns a function that will try all of the types so that we can just assign that function as the type directly. Remember to change the function's __name__, though, so the error messages look better (have the name be the type annotation string, e.g. Union[int, bool]).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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