springload / draftjs_exporter

Convert Draft.js ContentState to HTML
https://www.draftail.org/blog/2018/03/13/rethinking-rich-text-pipelines-with-draft-js
MIT License
83 stars 21 forks source link

Experiment with PEP-484 type hints #101

Closed thibaudcolas closed 4 years ago

thibaudcolas commented 6 years ago

Since Pyre got released, I've been thinking the exporter would be a good project to have type annotations in, either with Pyre or Mypy.

Corresponding PEPs:

Also worth checking out:


As far as I understand, in order to release anything useful, PEP-3107 is the bare minimum, and PEP-484 is a good baseline, so Python 3.5+ only. This means this package would need to drop support for Python 2.7 and 3.4. Wagtail, the main project relying on this package, has already dropped Python 2.7 compatibility, and the last version of Django to support Python 3.4 was v2.0 (https://docs.djangoproject.com/en/dev/faq/install/)

Edit: ^ I might be wrong, since the annotation syntax is supported starting with Python 3 the package should work in versions below 3.5. But type checking will only be doable starting in v3.5+?

This means that starting when Wagtail makes a new release without Django 2.0 support (or without Python 3.4 support, if that comes first), it will be possible to release the exporter with type annotations included (some time in 2019, see https://docs.wagtail.io/en/latest/releases/upgrading.html).

If anyone wants to experiment with this in the meantime, I would be interested to see what bugs this would surface. In my opinion the first step would be to use https://github.com/dropbox/pyannotate. I think there is a similar project from Google that does annotations based on instrumentation of running code.

thibaudcolas commented 4 years ago

Done in #123. See https://thib.me/python-static-type-checking-field-test.