Hypothesis: Clean up extra.django namespace

Created on 16 Dec 2018  路  7Comments  路  Source: HypothesisWorks/hypothesis

The Django extra has a few issues and inconsistencies, which are basically all because it predates our style guide and st.from_type respectively. It would be nice to:

  • replace hypothesis.extra.django.models.models with hypothesis.extra.django.from_model, deprecating the former. #35 would then obviously add from_form.
  • replace all the field-related inference with "just use st.from_type, and st.register_type_strategy for custom fields", because we really don't need two copies of that machinery and converting would trivially handle most of #1116. Nope, most of the detail lives on instances, not the types. Darn.
  • do nothing for optional fields by default, unless passed infer (models.models always infers unless passed use_default, unlike everything else)
enhancement legibility

All 7 comments

Hello!
I'd love to try this one out 馃槃

replace all the field-related inference with "just use st.from_type, and st.register_type_strategy for custom fields", because we really don't need two copies of that machinery and converting would trivially handle most of #1116.

@Zac-HD
I presume you mean the types should still be registered by us using st.register_type_strategy, and the end user wouldn't have to register any dm types themselves, correct?
Or do you mean we should drop inference and make it the user's responsibility?

Hi @GrigoriosGiann - this one is actually going to be a big and complicated change. I'd suggest starting with one of the 'good first issues' - perhaps one of the Django ones! - and then coming back to this once you've got a bit more experience working on Hypothesis :smile:

Thanks for the heads up @Zac-HD!
I'll try my luck at an easier issue as you recommended! 馃槃

Here's a quick stab at what the new version might look like: https://github.com/HypothesisWorks/hypothesis/compare/master...Zac-HD:django-api

That looks really great. I think it will be really easy to implement #35 into that framework!

That's the plan!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

DRMacIver picture DRMacIver  路  8Comments

Tinche picture Tinche  路  4Comments

SeanDS picture SeanDS  路  4Comments

thedrow picture thedrow  路  3Comments

sobolevn picture sobolevn  路  8Comments