dry-python / dry-python/classes

Typeclasses with several methods

未关闭
#83 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement help wanted
主要语言
Python
星标
730
派生
30
PR 合并指标
30 天内没有已合并 PR

描述

There's a common use-case when we need to create a type-class with several methods. Like:

```python
class Functor(Protocol[T]):
def map(self, function: Callable[[T], Functor[V]]) -> Functor[V]:
...

@classmethod
def from_value(cls, inner_value: V) -> Functor[V]:
...
```

Currently, there's no way we can do that.

I propose something like this:

```python
@typeclass
class Functor(Protocol[T]):
def map(self, function: Callable[[T], Functor[V]]) -> Functor[V]:
...

@classmethod
def from_value(cls, inner_value: V) -> Functor[V]:
...

```

I am not sure how to bound it to the actual implementation.

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。