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

Floating point default values not being rendered. #18

Closed
mashrurmorshed opened this issue Jun 8, 2021 · 2 comments
Closed

Floating point default values not being rendered. #18

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

Comments

@mashrurmorshed
Copy link

Describe the bug:
Decimal points are missed in default float values.

For example, if I have a function def foo(x = 0.01):, the docs will show x = 01. The markdown generator is unable to handle floating point default values.

Expected behaviour:

I expect my default floating point values to show up how I specified them in the code.

Steps to reproduce the issue:

For example, for the following function:

def foo(x : float = 0.01, y : int = 2) -> float:
    """Some function.

    Args:
        x (float, optional): A float number. Defaults to 0.01.
        y (int, optional): An integer. Defaults to 2.

    Returns:
        float: Their product.
    """     

    return x * y

Lazydoc renders it as:

image

Note the x=01, missing the ".".

Technical details:

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

Possible Fix:

Most likely there isn't any floating point support, or something's missing somewhere. I believe this should be an easy fix.

Additional context:

@mashrurmorshed
Copy link
Author

The bug is here

 if remove_package:
    # Remove all package path from signature
    signature = re.sub(r"([a-zA-Z0-9_]*?\.)", "", signature)

While attempting to remove package names, floating point defaults in the function signature are losing their floating decimal dot.

@LukasMasuch
Copy link
Contributor

@ID56 Thanks for reporting and investigating the issue :) I have pushed a small fix for this issue here: dd87065

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