Skip to content

Provide optional type hints in docs.python.org documentation #96186

@kkirsche

Description

@kkirsche

Documentation

The Python documentation currently provides function and method signatures for end users to view, such as:
https://docs.python.org/3/library/os.html#os.fsencode

I would like to request the option to display type hints in the documentation to facilitate architecture planning for experienced developers, teaching beginners about how they should expect to interact with a piece of code, or just assist discoverability of the hard work the typeshed team has put into typing Python.

As Python is typing-optional, I would suggest retaining the current documentation as a default, and providing a selector for typed / vs. non-typed (default) versions of the documentation as occurs in documentation for some frontend languages such as TypeScript vs. Javascript.

An example proposal would be to have it be site-wide or function-specific, similar to what Material-UI does with their example code:
CleanShot 2022-08-22 at 16 17 35@2x

In this image, below the Combo Box component, on the left hand side is a button to select either TS for typescript or JS for javascript code, which renders the example code with the specific details included.

Metadata

Metadata

Assignees

No one assigned

    Labels

    docsDocumentation in the Doc dirpendingThe issue will be closed if no feedback is provided

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions