dry-python / dry-python/classes

Support `Literal` types

Đang mở
#274 0 bình luận 0 reaction 0 người được giao Xem trên GitHub
enhancement
Ngôn ngữ chính
Python
Star
730
Fork
30
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.