dry-python / dry-python/classes

Support `Literal` types

Aperta
#274 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
enhancement
Lingua principale
Python
Stelle
730
Fork
30
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Descrizione

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

Guida per i contributori

Apri la guida per i contributori

Valutazione

Questa issue non è ancora stata valutata.

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.