Package: doc484
Generate PEP 484 type annotations from docstringsdoc484provides a script to find type declarations within your docstrings and convert them to PEP 484 type comments. It supports the three major docstring conventionsnumpy,google, andrestructuredText (sphinx)Regardless of docstring convention you choose, the types declared within your docstrings should following the guidelines inPEP 484, especially use of thetypingmodule, where necessary.Why Use This?If you answer affirmative to at least 2 of these, this project is probably for you:You’re stuck supporting python 2.7, so you have to use type comments, instead of the type annotations supported in 3.5+Your projects have existing docstrings with types that are already mostly correctYou find it easier to maintain and comprehend types specified alongside the description of an argumentExamplesBasicBeforefromtypingimportOptionaldefmaxlines(input,numlines=None):"""
    Trim a string to a maximum number of lines.

    Parameters
    ----------
    input : str
    numlines : Optional[int]
        maximum number of lines

    Returns
    -------
    str
    """ifnumlinesisNone:returninputreturn'\n'.join(input.split('\n')[:numlines])Afterdoc484fromtypingimportOptionaldefmaxlines(input,numlines=None):# type: (str, Optional[int]) -> str"""
    Trim a string to a maximum number of lines.

    Parameters
    ----------
    input : str
    numlines : Optional[int]
        maximum number of lines

    Returns
    -------
    str
    """ifnumlinesisNone:returninputreturn'\n'.join(input.split('\n')[:numlines])The file is now properly inspectable by mypy or PyCharm.AdvancedA more complex example demonstrates some of the added readability that comes from specifying types within your docstrings.
Below we use numpy format to document a generator of tuples:Beforefromtypingimport*defitercount(input,char):"""
    Iterate over input strings and yield a tuple of the string with `char`
    removed, and the number of occurrences of `char`.

    Parameters
    ----------
    input : Iterable[str]
    char : str
        character to remove and count

    Yields
    ------
    stripped : str
        input string with all occurrences of `char` removed
    count : int
        number of occurrences of `char`
    """forxininput:yieldx.strip(char),x.count(char)Afterdoc484fromtypingimport*defitercount(input,char):# type: (Iterable[str], str) -> Iterator[Tuple[str, int]]"""
    Iterate over input strings and yield a tuple of the string with `char`
    removed, and the number of occurrences of `char`.

    Parameters
    ----------
    input : Iterable[str]
    char : str
        character to remove and count

    Yields
    ------
    stripped : str
        input string with all occurrences of `char` removed
    count : int
        number of occurrences of `char`
    """forxininput:yieldx.strip(char),x.count(char)Installingpip install doc484Usagedoc484 -hBy defaultdoc484willnotmodify files, instead it will print out a diff of what would be modified.  When you’re ready to make changes, add the--writeflag.Check the scripts directory for an example of how to automatically rundoc484on modified files in your git or mercurial repository.ConfigurationYou can override any of the command line options using an ini-style configuration file.
By default,doc484looks for a setup.cfg file in the current working directory, but you can also provide a config explicitly using the--configoption.For example, to override the number of processes to use when converting, and specify the docstring format for the project, add this to your setup.cfg and rundoc484from the directory where this config file resides:[doc484]processes=12format=numpyTODOautomatically inserttypingimportsadd option to convert docstrings to function annotations (for python 3.5+)finish support for fixing non-PEP484-compliant docstrings (e.g.list of str)convertdoctypesutility script to python?