Type Hinting Support

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.

Is this what you're asking us to implement for the SDK? typing — Support for type hints — Python 3.10.4 documentation

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.

Yes, exactly that.

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

And this is how it would be with it:
image

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 patch_user(self, user_id, 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.patch_user(user_id, 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 patch_user(self, user_id: str, body: UpdateUser, **kwargs) -> User:
""" Rest of the preexisting docstring here... """

Please correct me if I'm wrong Adrian

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:
image

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

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)

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

Thanks

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

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