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

Tuple in return type signature showing as "uple", because of lstrip. #19

Closed
mashrurmorshed opened this issue Jun 8, 2021 · 2 comments
Closed
Labels
bug Something isn't working

Comments

@mashrurmorshed
Copy link

Describe the bug:

When the return type is tuple, it is being rendered as "uple" instead.

Expected behaviour:
I expect it to show tuple.

Steps to reproduce the issue:

def foo(x : int = 1, y: int = 2, z: tuple = (0.001, 2)) -> tuple:
    """Some function.

    Args:
        x (int, optional): An integer. Defaults to 1.
        y (int, optional): An integer. Defaults to 2.
        z (tuple, optional): Tuple. Defaults to (0.001, 2).

    Returns:
        tuple: (x, y).
    """     
    return (x, y)

Lazydoc renders this as:

image

Note the "uple".

Technical details:

  • Host Machine OS (Windows/Linux/Mac): Linux
  • Browser (Chrome/Firefox/Safari): Firefox

Possible Fix:
Again, seems to be a cosmetic issue like #18

Additional context:

@mashrurmorshed mashrurmorshed added the bug Something isn't working label Jun 8, 2021
@mashrurmorshed
Copy link
Author

Out of curiosity, I took a glance through your source code. The problem is quite easy to trace; it comes from here.

return_type = return_type.lstrip("typing.")

What this does is if return type starts with any of the characters in (t, y, p, i, n, g, .) it'll be stripped. E.g:

"tuple".lstrip("typing") --> "uple"

Even more problematic: one of the most basic types, "int" has all 3 characters among (t, y, p, i, n, g, .) and thus gets completely deleted.

"int".lstrip("typing") --> ""

The fix would be to swap out lstrip, which has a potentially dangerous behaviour, with some re expression.

@mashrurmorshed mashrurmorshed changed the title Tuple in return type signature showing as "uple". Tuple in return type signature showing as "uple", because of lstrip. Jun 8, 2021
@lukasmasuch
Copy link
Contributor

@ID56 Thanks for reporting this issue as well :) I have pushed a small fix for this issue here: dd87065 Will be included in the next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants