Search code examples
pythonpython-sphinxpython-typing

Sphinx and TypedDict


I defined in my code a TypedDict like this:

class VectorDict(TypedDict):
    x: float
    y: float
    z: float

and when I generate the documentation, I get the following result:

How can I suppress everything after -> and/or modify it?


Solution

  • The solution is to add a docstring:

    class VectorDict(TypedDict):   
        """
        Description here
        """
    
        x: float
        y: float
        z: float
    

    With this I obtain:

    enter image description here