Skip to content

Support Literal types  #274

@sobolevn

Description

@sobolevn

After we have delegate in-place we can use Literal types.

But, now they are not supported.
Ideally, something like this should work:

from classes import typeclass, AssociatedType, Supports
from typing_extensions import Literal

class SomeDelegate(object):
    ...  # TODO: write proper `__instancecheck__`

class A(AssociatedType):
    ...

@typeclass(A)
def some(instance) -> int:
    ...

@some.instance(Literal[1], delegate=SomeDelegate)
def _some_tuple(instance: Literal[1]) -> int:
    return instance

def test(i: Supports[A]):
    return some(i)

some(1)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions