Docstring formats at a glance

  • Google (Python): Args: / Returns: / Raises: / Example: sections with indented content
  • NumPy (Python): Parameters / Returns / Raises sections with dashes underlines
  • Sphinx/RST (Python): :param name: / :returns: / :raises ExType: inline directives
  • JSDoc (JS/TS): @param / @returns / @throws / @deprecated / @example tags
  • Javadoc (Java): @param / @return / @throws / @see tags

Question 0 of 5

Read this Python docstring and answer: what does the function return when no user is found?

def get_user(user_id: int) -> Optional[User]:
    """Retrieve a user by their ID.

    Args:
        user_id: The unique identifier of the user.

    Returns:
        The User object if found, or None if no user exists
        with the given ID.
    """