Skip to content

Support for type aliases #6516

@clo-vis

Description

@clo-vis

Describe the Features

Type aliases are not supported. For example, with:

type Alias = int

class State(rx.State):
    count: Alias = 0

I get TypeError: Unsupported type Alias for guess_type. (the error message could also be better - wtf is "guess_type"?)

The algorithm that determines guess_type could try to resolve type aliases before giving up.

  • Show an example / use cases for the new feature.
class State(rx.State):
    a: Literal["amber", "blue", ... many other colors, "yellow"] 
    b: Literal["amber", "blue", ... many other colors, "yellow"] 

would become

type ColorSchema = Literal["amber", "blue", ... many other colors, "yellow"]

class State(rx.State):
    a: ColorSchema 
    b: ColorSchema

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestA feature you wanted added to reflex

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions