[Python] Type hinting and having docs information

Discussão em 'Python' iniciado por Stack, Agosto 29, 2025.

  1. Stack

    Stack Membro Participativo

    I have some method which takes two parameters, both of them are type hinted as "str". But I would also like to have some description attached to them. But most examples I found also want you to include the type in the docstring. Is there some neat way where I can keep the type hint outside of docstring but keep the description?

    def extract_files(
    source_dir: str,
    working_dir: str,
    ) -> None:
    """
    Args:
    source_dir (str): some_important_description_1
    working_dir (str): some_import_description_2
    """

    Continue reading...

Compartilhe esta Página