dry-python / dry-python/classes

Hypothesis integration

オープン
#234 コメント 2 件 リアクション 1 件 担当者 0 名 GitHub で見る
enhancement
主要言語
Python
スター
730
フォーク
30
PR マージ指標
30日以内にマージされた PR はありません

説明

Right now we don't test `classes` with `hypothesis` at all.

But, I have a great idea (at least it seems to me like so) of adding a hypothesis plugin, similar to one we have in `returns`: https://github.com/dry-python/returns/blob/master/returns/contrib/hypothesis/laws.py

What should it do?

- `check_typeclass(typeclass_instance)` will check that for all existing types and protocols some valid return type is produced. For example, `@typeclass def some(instance) -> str` must produce `str` for all `instance`, `protocol`, and supported types and it must produce `NotImplementedError` for types that are not supported
- Looks like `check_typeclass` must have `allow_instances`, `allow_protocols`, `allow_unknown` kw `bool` arguments to configure what types we actually need in a resulting strategy

It would be a nice companion to our `mypy` check.

@Zac-HD do you like it? Maybe you have any other ideas?

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。