dry-python / dry-python/classes
Support `Literal` types
Đang mở
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
Đánh giá
Issue này chưa được đánh giá.