Legacy Dev Forum Posts

 View Only

Sign Up

  • 1.  Type Hinting Support

    Posted 06-05-2025 18:08

    Adrian_Santamaria | 2022-04-05 16:03:33 UTC | #1

    Hello

    I was wondering if there are any plans to include Type Hints in the Python SDK package. It is a tool that greatly speeds up the developing process thanks to the autocompletion.


    tim.smith | 2022-04-05 16:07:21 UTC | #2

    Is this what you're asking us to implement for the SDK? https://docs.python.org/3/library/typing.html

    Apologies for my ignorance, I'm not a Python developer. I did a quick google search and that looks good, but want to make sure we're on the same page before sending it on to the SDK team.


    Adrian_Santamaria | 2022-04-05 16:28:42 UTC | #3

    Yes, exactly that.

    This is how it is now (without type hinting):

    And this is how it would be with it:


    Carson_Draper | 2022-04-05 22:08:10 UTC | #4

    I agree with this suggestion, this would be a nice feature. Just to clarify things a bit for Adrian, there are type hints in the package's source code. However, these type hints are within Class Method doc strings and subsequently many IDEs will not recognize the type hints.

    To give an example this is the PATCH /users/{user id} class method declaration in the source code:

    def patchuser(self, userid, body, **kwargs): """ Update user

    This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please define a callback function to be invoked when receiving the response.

    def callback_function(response):

    pprint(response)

    thread = api.patchuser(userid, body, callback=callback_function)

    :param callback function: The callback function for asynchronous request. (optional) :param str user_id: User ID (required) :param UpdateUser body: User (required) :return: User If the method is called asynchronously, returns the request thread. """

    What Adrian is asking for is for class methods to be type hinted like so:

    def patchuser(self, userid: str, body: UpdateUser, **kwargs) -> User: """ Rest of the preexisting docstring here... """

    Please correct me if I'm wrong Adrian


    Adrian_Santamaria | 2022-04-06 08:52:27 UTC | #5

    Exactly, and also in the Classes properties too:

    class User(object):

    ...

    @property def division(self) -> Division: """ Gets the division of this User. The division to which this entity belongs.

    :return: The division of this User. :rtype: Division """ return self._division

    Also, as it is now, it point out false errors:

    Whereas if it had type hinting, it would be something like this:

    That forces us to work with the type checking deactivated, or else to have our code full of false error alerts.

    (FWIW, I'm using Pylance for autocompletion in VS Code)


    Carson_Draper | 2022-05-03 17:22:54 UTC | #6

    Is this planned to be implemented in the near future? Would be a great QOL update for developers.

    Thanks


    John_Carnell | 2022-05-03 18:21:41 UTC | #7

    Hi Carson,

    We did not have this on our roadmap in the near future. I have never been a hard code Python developer but type hints do look extremely useful.

    I will add it to a discussion with our product manager @Becky_Powell.

    Thanks, John Carnell Manager, Developer Engagement


    system | 2022-06-03 18:22:36 UTC | #8

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 14172