PyCQA / docformatter

Formats docstrings to follow PEP 257
https://pypi.python.org/pypi/docformatter
MIT License
524 stars 61 forks source link

docformatter weird behaviour #221

Closed jonyscathe closed 1 year ago

jonyscathe commented 1 year ago

Say I have a file that contains only:

def my_function(
    param1,
    param2,
    param3,
    param_file,
    param4,
) -> None:
    """
    Fit and save the wallet model, including the internal pipeline and the wallet wrapper.

    :param param1: Model data.
    :param param2: Data from build_wallet_features that would actually be used in production.
    :param param3: number of cv splits.
    :param param_file: filename.
    :param param4: hard rule settings.
    """

If I run docformatter over that file with arguments --black --in-place --pre-summary-newline -- wrap-summaries=120 --wrap-descriptions=120 then I get the output:

def my_function(
    param1,
    param2,
    param3,
    param_file,
    param4,
) -> None:
    """
    Fit and save the wallet model, including the internal pipeline and the wallet wrapper.

    :param param1: Model data. :param param2: Data from build_wallet_features that would actually be used in production.
    :param param3: number of cv splits. :param param_
    file:
    :param param1: Model data.
    :param param2: Data from build_wallet_features that would actually be used in production.
    :param param3: number of cv splits.
    :param param_file: filename.
    :param param4: hard rule settings.
    """

So docformatter has kept my 5 lines of parameter descriptions, but added three weird line above that.... The issue seems to be when there is a parameter ending with _file.

This was not an issue in 1.6.5, but is an issue in 1.7.1.

Not too sure how to fix this other than renaming all my variables.

weibullguy commented 1 year ago

The problem is actually this pattern file: It's being picked up as a URL and wrapping everything before file: as the description leading up to the URL.

I have the fix, so I'll make it part of v1.7.2 which should be released in the next few days. I would stick with v1.6.5 until I fix this rather than renaming variables.

weibullguy commented 1 year ago

@jonyscathe this should be fixed in v1.7.2-rc4.

weibullguy commented 1 year ago

Closing this issue to #231.