dry-python / dry-python/classes

Hypothesis integration

Aperta
#234 2 commenti 1 reazione 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

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?

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.