terrencepreilly / darglint

A python documentation linter which checks that the docstring description matches the definition.
MIT License
481 stars 41 forks source link

Colons (`:`) in docstring drastically slow down darglint #198

Open paw-lu opened 2 years ago

paw-lu commented 2 years ago

Using colons (:) in docstrings drastically slows down darglint—enough to make some linting sessions time out if there are enough arguments. This is unfortunate because rst uses : for cross-references.

For example, this simple function takes 2m2s to complete on my machine.

def foo():
    """Summary

    Args:
        file (Any):
            A path to a Jupyter Notebook file.
        theme (str): The theme to use for syntax highlighting. May
            be ``'ansi_light'``, ``'ansi_dark'``, or any
            `Pygments theme`_. By default ``'ansi_dark'``.
        plain (bool): Only show plain style. No decorations such as
            boxes or execution counts. If set to :py:data:`None`
            will autodetect. By default :py:data:`None`.
        unicode (Optional[bool]): Whether to use unicode characters
            to render the notebook. If set to :py:data:`None` will
            autodetect. By default :py:data:`None`.
        hide_output (bool): Do not render the notebook outputs. By
            default :py:data:`False`.
        nerd_font (bool): Use nerd fonts when appropriate. By
            default :py:data:`False`.
        files (bool): Create files when needed to render HTML
            content. By default :py:data:`True`.
        negative_space (bool): Whether render character images in
            negative space. By default :py:data:`True`.
        hyperlinks (bool): Whether to use hyperlinks. If
            :py:data:`False` will explicitly print out path. If set
            to :py:data:`None` will autodetect. By default
            :py:data:`None`.
        hide_hyperlink_hints (bool): Hide text hints of when content
            is clickable. By default :py:data:`False`.
        images (Optional[str]): Whether to render images. If set to
            :py:data:`None` will autodetect. By default
            :py:data:`None`.
    """
    ...

If I just remove the (extra) semicolons,

- :py:data:
+ pydata

Then it halves the time for the linting process (52s vs 2m2s).


Thanks for the great work here!