Skip to content

Literal type math #11990

Open
Open
@sobolevn

Description

@sobolevn

I am working on feature where reveal_type(1 + 2) will reveal Literal[3].

Types that I want to support:

  • int
  • str
  • bool

And these operations:

_SUPPORTED_LITERAL_OPERATIONS: Final = {
    int: ('+', '-', '*', '//'),  # `/` returns `float`
    str: ('+',),
    bool: ('and', 'or'),
}

So, True or False is revealed as Literal[True].

I will finish some test later today and send a PR in the morning.

Снимок экрана 2022-01-14 в 0 44 36

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions