Neil Williams created THRIFT-5139:
-------------------------------------
Summary: Type hinting for Python library
Key: THRIFT-5139
URL: https://issues.apache.org/jira/browse/THRIFT-5139
Project: Thrift
Issue Type: Improvement
Components: Python - Library
Reporter: Neil Williams
Similarly to THRIFT-4181, it'd be useful to have type hints for the Python
Thrift library itself.
There are a few possible approaches:
1) Add type stubs to the [typeshed|[https://github.com/python/typeshed]]. This
would require no changes to the library itself but also would mean the types
are always potentially out of sync with the library and come from different
places.
2) Add type stubs in separate .pyi files within the main library codebase. This
allows the library to maintain compatibility with Python versions lower than
3.5 while also providing proper annotations to modern implementations. Like
with typeshed it runs the risk of types and implementations being out of sync,
but the risk should be lower because the code lives side-by-side.
3) Add type annotations directly to the Python code. The code and types would
be combined and so would always stay in sync. This would essentially break
compatibility with Python 3.4 and lower (incl. Python 2.7). While this sounds
drastic, [Python 3.4 went end-of-life in March 2019 and Python 2.7 in January
2020|https://devguide.python.org/devcycle/#end-of-life-branches]. This is the
most drastic option, but explicitly dropping support for those versions would
also open up a bunch of cleanups in the code so might be desirable for other
reasons.
Do you all have any suggestion for which approach to take? I'd be happy to do
the type hinting itself if I know the direction to take.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)