Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed docstring warnings and improvements #93

Merged
merged 26 commits into from
Jan 26, 2024

Conversation

hassaanfarooq01
Copy link
Member

@hassaanfarooq01 hassaanfarooq01 commented Jan 24, 2024

  • Fixed mkdocs docstring warnings
  • Added improvements docstring texts

@hassaanfarooq01 hassaanfarooq01 requested review from kalenmike and glenn-jocher and removed request for kalenmike January 24, 2024 17:38
@glenn-jocher
Copy link
Member

@hassaanfarooq01 they're all fixed!!

@glenn-jocher
Copy link
Member

@hassaanfarooq01 oh wait, this branch doesn't have the Docs checking action, so it's hard to tell haha. I think you're good to merge this into the CI branch, or vice versa, so you can tell if there are any warnings remaining.

@glenn-jocher
Copy link
Member

glenn-jocher commented Jan 24, 2024

@hassaanfarooq01 ok I just built locally. All the warnings are gone (good job)!

But there's one problem remaining. Every inlined return that does not have a variable name needs to be surrounded by parentheses in the docstrings, i.e.: here we need (bool) instead of just bool. Basically, types always need parentheses, otherwise mkdocstrings will not display them correctly (see screenshot) below:

def example_function(arg1: int, arg2: int) -> bool:
    """
    Example function that demonstrates Google-style docstrings.

    Args:
        arg1 (int): The first argument.
        arg2 (int): The second argument.

    Returns:
        (bool): True if successful, False otherwise.

    Examples:
        >>> result = example_function(1, 2)  # returns False
    """
    if arg1 == arg2:
        return True
    return False

Example screenshot showing problem

Screenshot 2024-01-24 at 18 49 24

To fix this you would just put parenthesis around the return type: (requests.Response)

@hassaanfarooq01
Copy link
Member Author

hassaanfarooq01 commented Jan 25, 2024

@hassaanfarooq01 ok I just built locally. All the warnings are gone (good job)!

But there's one problem remaining. Every inlined return that does not have a variable name needs to be surrounded by parentheses in the docstrings, i.e.: here we need (bool) instead of just bool. Basically, types always need parentheses, otherwise mkdocstrings will not display them correctly (see screenshot) below:

def example_function(arg1: int, arg2: int) -> bool:
    """
    Example function that demonstrates Google-style docstrings.

    Args:
        arg1 (int): The first argument.
        arg2 (int): The second argument.

    Returns:
        (bool): True if successful, False otherwise.

    Examples:
        >>> result = example_function(1, 2)  # returns False
    """
    if arg1 == arg2:
        return True
    return False

Example screenshot showing problem

Screenshot 2024-01-24 at 18 49 24 To fix this you would just put parenthesis around the return type: `(requests.Response)`

mkdocs didn't raised warring for that therefore didn't get that. But yeah let me add it.

@glenn-jocher
Copy link
Member

Yeah for this it doesn't raise warnings unfortunately, it's hard to check automatically so often times I just spot the tables built incorrectly in the published docs and then go fix them in the ultralytics docs.

Ok let me know when they're updated and I'll review again!

"""
Get the URL of the model weights.

Args:
weight (str, optional): Type of weights to retrieve. Defaults to "best".

Returns:
str or None: The URL of the specified weights or None if not available.
Optional[str]: The URL of the specified weights or None if not available.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needs parentheses

@glenn-jocher
Copy link
Member

@hassaanfarooq01 there are number of corrections required here, this is very far from ready to merge.

Most importantly ALL usage of Optional requires brackets rather than parentheses.

PyCharm displays this clearly in your PR, you should probably use it when viewing your code.

Screenshot 2024-01-25 at 13 57 26

@hassaanfarooq01
Copy link
Member Author

hassaanfarooq01 commented Jan 25, 2024

@hassaanfarooq01 there are number of corrections required here, this is very far from ready to merge.

Most importantly ALL usage of Optional requires brackets rather than parentheses.

PyCharm displays this clearly in your PR, you should probably use it when viewing your code.

Screenshot 2024-01-25 at 13 57 26

ohhh! it's stupid mistake. even wrote correct in docstring 🫣
yeah using vscode will jump to pycharm.

@glenn-jocher
Copy link
Member

@hassaanfarooq01 ok let me know when it's ready, thanks!

@hassaanfarooq01
Copy link
Member Author

hassaanfarooq01 commented Jan 26, 2024

@glenn-jocher I have reviewed the documentation thoroughly and implement the necessary changes to address issues with ui, with that also tried to add Notes and proper descriptions that will be helpful visually.

I know it should be done first time, but I was assuming to ui catch that automatically

@glenn-jocher
Copy link
Member

@hassaanfarooq01 ok thanks, I will take a look today!

@glenn-jocher
Copy link
Member

@hassaanfarooq01 looks much better! I think all the issues are resolved now. Nice work!

hub_sdk/modules/projects.py Outdated Show resolved Hide resolved
hub_sdk/modules/models.py Show resolved Hide resolved
hub_sdk/base/server_clients.py Show resolved Hide resolved
hub_sdk/base/server_clients.py Show resolved Hide resolved
hub_sdk/base/server_clients.py Show resolved Hide resolved
hub_sdk/base/api_client.py Outdated Show resolved Hide resolved
hub_sdk/base/auth.py Outdated Show resolved Hide resolved
hub_sdk/base/auth.py Outdated Show resolved Hide resolved
hub_sdk/base/server_clients.py Outdated Show resolved Hide resolved
hub_sdk/modules/datasets.py Outdated Show resolved Hide resolved
@kalenmike kalenmike merged commit 020ca35 into develop Jan 26, 2024
@kalenmike kalenmike deleted the fix/mkdocs-docstring-warnings branch January 26, 2024 15:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants