Eel
Eel copied to clipboard
Refinement of type annotations to reflect move to Python>=3.7
PR #577 introduced type annotations, but had to do some fiddly bits to work around some of the limitations to type annotations in Python 3.6, such as the unavailability of __future__.annotations. Eel has since dropped support for Python 3.6.
Typing refinements
- This PR generally brings the type annotations up to the feature set of Python 3.7 and tidies them in places.
- Additionally it now introduces a
TypedDictsolution to_start_args/OptionsDictT. This allowed for further type narrowing and better typing checks (with at least one type mismatch caught and fixed in the process), as well as passing the advantages of reporting typing issues with start_args back to users in a more insightful manner. - In the process of the work to
_start_args/OptionsDictT, I have also moved the defaults into the definition ofeel.start(), so that users will get proper type hints and function signatures covering all the possible start args.
Additional improvements
- Dropped dependency on
whichcraftin favour ofshutil.which(), since this is part of the standard library with all supported Python versions now (updated in ba08df0 -> 7f6d51e). - To preserve the information on the _start_args that was present in comments in the source,
eel.start()was augmented with a proper docstring to document each of the arguments. - Because having only
eel.start()with a proper docstring seemed odd, I've added proper docstrings to the other publicly exposed functions, too. - All new docstrings are in reStructuredText so that they will be readily compatible with Sphinx autodoc, should Sphinx documentation be produced in the future.