Skip to content

[community] Improving docstrings and type hints #9567

Description

@a-r-r-o-w

There are many instances in the codebase where our docstring/typing convention is not followed. We'd like to work on improving this with your help!

Our convention looks like:

def function_name(parameter_1: Union[str, List[str]], parameter_2: Optional[int] = None, parameter_3: float = 42.0) -> Civilization:
    r"""
    Function that creates a simulation.

    Args:
        parameter_1 (`str` or `List[str]`):
            Description of game level.
        parameter_2 (`int`, *optional*):
            Kardashev scale of civilization.
        parameter_3 (`float`, defaults to `42.0`):
            Difficulty scale.

    Returns:
        [`~simulations.objects.Civilization`]
            A civilization simulation with provided initialization parameters.
    """

Some examples that don't follow the docstring convention are:

  • this: missing explanations
  • this: does not contain mixin-related documentation whereas as this does
  • this: function explanation after "Args", but should be before
  • this: same reason as above
  • this: incorrect indentation

There are also many places where docstrings are completely missing or inadequately explained. If you feel something needs an improvement, you can open a PR with your suggestions too! Additionally, type hints are not appropriate/correctly used at many occurrences and mismatch the accompanying docstrings - these could use an improvement too!

Please limit your PRs to changes to a single file in each PR. Changes must be only related to docstrings/type hints. Feel free to ping either @yiyixuxu, @stevhliu or me for reviews.

Activity

  1. whtssub commented on Oct 2, 2024

    @whtssub

    Hi @a-r-r-o-w I'd like to take this up, please let me know if there are any other prerequisites I should be aware of before submitting a PR against this issue 🙂

  2. a-r-r-o-w commented on Oct 2, 2024

    @a-r-r-o-w
    ContributorAuthor

    Not prerequisites I can think of off the top of my head. Just that the PRs should be limited in scope as mentioned. You can maybe look at the Diffusers contribution guide (and philosophy, if you're interested)

  3. charchit7 commented on Oct 2, 2024

    @charchit7
    Contributor

    I'll take up some of these.

  4. yijun-lee commented on Oct 4, 2024

    @yijun-lee
    Contributor

    I’m also interested in this work. Could you let me know about the current progress? @SubhasmitaSw @charchit7

  5. charchit7 commented on Oct 4, 2024

    @charchit7
    Contributor

    Hey @yijun-lee, I've been caught up with some work, unfortunately, but I’ll work on this over the weekend or later today. If you want to get started on any of these tasks, feel free to go ahead and let us know, so we can pick up whatever is left.

  6. yijun-lee commented on Oct 4, 2024

    @yijun-lee
    Contributor

    Oh, actually, I think I’ll be starting this weekend as well. If we proceed separately, it would be good to inform each other through comments or other means. Have a good day :) @charchit7

  7. charchit7 commented on Oct 4, 2024

    @charchit7
    Contributor

    Sure, @yijun-lee, that works!
    you too :)

  8. Divyam01325 commented on Oct 4, 2024

    @Divyam01325
    Contributor

    Hello there guys, I'd also like to contribute in this issue. I'm sorry I didn't really drop in a message here yet but I hope this PR helps push things forward! A g'day to all.

  9. a-r-r-o-w commented on Oct 4, 2024

    @a-r-r-o-w
    ContributorAuthor

    Feel free to take up as many files as you want (one file per PR however)! The ones mentioned in the issue description are just a few examples, but there are probably hundreds of files that could use improvements. Please keep them coming, thanks

  10. jeongiin commented on Oct 5, 2024

    @jeongiin
    Contributor

    Hello! I'm also following this issue with interest. I’ve submitted my first PR, so please let me know if there are any mistakes! Have a great day!

  11. ahnjj commented on Oct 5, 2024

    @ahnjj
    Contributor

    Hello! Thanks for holding interesting issue! I'm fully circled for this new work ! 🙆🏻‍♀️ 🙆🏻‍♀️
    I also have opened my PR, please let me know if I missed something !

    • Q. which should I prioritize modern python docstring conventions or unity of that file (e.g. expression) ?
  12. Ashutoshjangam commented on Oct 5, 2024

    @Ashutoshjangam

    @a-r-r-o-w hi, i wank to work on it

  13. 11 remaining items

  14. RogerSinghChugh commented on Oct 20, 2024

    @RogerSinghChugh
    Contributor

    Hi I would love to be of help here.
    I have made some additions to the docstrings in src/diffusers/training_utils.py.
    Would love to get your feedback on the PR :)

  15. added 3 commits that reference this issue on Nov 10, 2025
    67f931b
    b21f59a
    38cf8fd
  16. delmalih commented on Nov 10, 2025

    @delmalih
    Contributor

    Hi 👋

    I'm working on improving the docstrings and type hints for all scheduler files. I've already opened two PRs:

    I plan to continue with the other schedulers in the src/diffusers/schedulers/ directory. I'll submit one PR per file as recommended.

    Let me know if there are any specific schedulers you'd like me to prioritize or if you have any feedback on my approach. Thanks!

  17. added a commit that references this issue on Nov 13, 2025
    4b68de7
  18. added a commit that references this issue on Nov 13, 2025
    6fe4a6f
  19. delmalih commented on Jul 7, 2026

    @delmalih
    Contributor

    Hi @stevhliu ! Sorry for the long silence since my last contribution back in February. I had a baby, so I've been quite busy 🙂 Will start submitting PRs again soon!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions