Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Is there something like "f-docstring"?

I want to mention default values for function arguments in the function descriptions (docstrings).
What I don’t want to do is to manually edit the docstrings, whenever I try out new default values

So, is there something like f-docstrings, that enables dynamically updating the decstrings content ?

I tried

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

def check_availability(self, checks: int = 10, timeout: float = 1.5, apply_filters: bool = False) -> list[dict]:
    f'''
    Checks which proxies on "https://free-proxy-list.net/" are really available 
    by requesting visible IP returned by "http://icanhazip.com"  

    Args:
        checks (int): amount of checks, corresponds to the first entries in the considered proxies list); defaults to {checks}
        timeout (float): accepted response waiting time in seconds.
        apply_filters (bool): If True a before generated filtered proxies list is considered for the checks, otherwise the entire list is considered.

    Returns:
        list[dict]: list of confirmed proxies
    '''

When I hover over a call of that method I get this:
enter image description here

This is how it shouldf look like:

enter image description here

>Solution :

whenever I try out new default values

Two things:

  1. When experimenting, just pass the actual values to the function rather than updating the default values every time. These are function arguments for a reason.
  2. In the screenshot you provided, the default values are clearly visible outside the docstring, in the method definition. You might consider omitting default values from the docstring entirely, since they’re visible in the method declaration.
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading