mozilla / bugbug

Platform for Machine Learning projects on Software Engineering
Mozilla Public License 2.0
504 stars 311 forks source link

Add docstrings to functions in `bugbug/bugzilla.py` #3360

Open suhaibmujahid opened 1 year ago

suhaibmujahid commented 1 year ago

Adding Args and Returns should follow Google Style Python Docstrings. The docstrings should not include type annotations; these types should be added to the function itself.

Karnankita04 commented 1 year ago

@suhaibmujahid I would like to work on this issue!

skynette commented 1 year ago
def get_ids(params: dict) -> List[int]:
    """
    Retrieves a list of bug IDs from Bugzilla based on the given parameters.

    Args:
        params (dict): A dictionary of parameters to pass to the Bugzilla API.

    Returns:
        list of int: A list of bug IDs.

    Raises:
        None
    """
    assert "include_fields" not in params or params["include_fields"] == "id"

    old_CHUNK_SIZE = Bugzilla.BUGZILLA_CHUNK_SIZE
    try:
        Bugzilla.BUGZILLA_CHUNK_SIZE = 7000

        all_ids = []

        def bughandler(bug):
            all_ids.append(bug["id"])

        params["include_fields"] = "id"

        Bugzilla(params, bughandler=bughandler).get_data().wait()
    finally:
        Bugzilla.BUGZILLA_CHUNK_SIZE = old_CHUNK_SIZE

    return all_ids

This is an example for get_ids function, @suhaibmujahid I'm I on track with this?

suhaibmujahid commented 1 year ago

@suhaibmujahid I would like to work on this issue!

@Karnankita04 Anyone can work on any issue as long as it is not linked to an open pull request.

It's always good to have descriptive and informative docstrings ...

@fadebowaley Please do not post auto-generated content in this project

This is an example for get_ids function, @suhaibmujahid I'm I on track with this?

@skynette It will be more efficient to give feedback on code in a PR than here in the issue. Here some notes:

  1. See in the issue description: "docstrings should not include type annotations"
  2. You do not need to include Raises if the function is not raising specific exceptions
  3. The comment should start right after """
skynette commented 1 year ago

okay noted, will make a PR soon

fadebowaley commented 1 year ago

@suhaibmujahid @Karnankita04 I apologise if my content was misleading. Thank you for further explanation on Docstring and type annotations