facultyai / faculty-sync

Synchronise a local directory with your Faculty platform workspace
https://pypi.org/project/faculty_sync/
Apache License 2.0
10 stars 1 forks source link

Add type annotations for screens.components subpackage #19

Open pbugnion opened 6 years ago

pbugnion commented 6 years ago

This is an attempt at introducing greater rigour in how we use mypy types. This PR is mostly supposed to be a starting point for discussions, not necessarily useful in itself.

The sml_sync.screens.components subpackage now has full typechecking, including on all private methods. This subpackage heavily dependent on prompt_toolkit, which doesn't have type annotations, so I've written some stubs by just reading the code on GitHub.

This exercise has lead to some tidying of import structures (we were frequently importing classes from prompt_toolkit.layout.containers or prompt_toolkit.layout.controls, instead of directly from prompt_toolkit.layout, for instance), so it's been somewhat beneficial for the codebase. Nevertheless, type annotations do add complexity, so I'm open to deciding we don't want these.

If we do decide to merge this, we should test it in Travis.

To reproduce, run:

mypy sml_sync