Uploaded image for project: 'Thrift'
  1. Thrift
  2. THRIFT-5139

Type hinting for Python library

    XMLWordPrintableJSON

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Python - Library
    • Labels:
      None

      Description

      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. 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.

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              spladug Neil Williams
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: