You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@thrift.apache.org by "Jens Geyer (Jira)" <ji...@apache.org> on 2024/08/21 21:00:00 UTC

[jira] [Resolved] (THRIFT-5139) Type hinting for Python library

     [ https://issues.apache.org/jira/browse/THRIFT-5139?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Jens Geyer resolved THRIFT-5139.
--------------------------------
    Fix Version/s: 0.21.0
         Assignee: Jens Geyer
       Resolution: Duplicate

> 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
>            Assignee: Jens Geyer
>            Priority: Major
>             Fix For: 0.21.0
>
>          Time Spent: 11h 20m
>  Remaining Estimate: 0h
>
> 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.20.10#820010)