dry-python / dry-python/classes

Support `Literal` types

Abierto
#274 0 comentarios 0 reacciones 0 asignados Ver en GitHub
enhancement
Lenguaje dominante
Python
Estrellas
730
Forks
30
Métricas de merge de PR
Sin PR fusionados en 30 d

Descripción

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

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

```python
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)
```

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.