duplicate content after running docformatter
finswimmer opened this issue · 2 comments
finswimmer commented
Hey,
I've updated docformatter
to 1.7.5 and discovered a strange behavior.
Given this minimal example:
async def get_rendered_template(
template_filename: str, parameters: dict[str, Any], jinja_loader: BaseLoader
) -> str:
"""Render the given Template.
:param template_filename: name of the template file
:param parameters: Parameters passed to the template
:param jinja_loader: Loader to find templates path, see https://jinja.palletsprojects.com/en/2.11.x/api/#loaders
:return: Returns the rendered Jinja2 Template, which is a valid LaTex file
"""
...
This is what it looks like after running docformatter
:
async def get_rendered_template(
template_filename: str, parameters: dict[str, Any], jinja_loader: BaseLoader
) -> str:
"""Render the given Template.
:param template_filename: name of the template file :param
parameters: Parameters passed to the template :param jinja_loader:
Loader to find templates path, see
https://jinja.palletsprojects.com/en/2.11.x/api/#loaders
:param template_filename: name of the template file
:param parameters: Parameters passed to the template
:param jinja_loader: Loader to find templates path, see
https://jinja.palletsprojects.com/en/2.11.x/api/#loaders
:return: Returns the rendered Jinja2 Template, which is a valid
LaTex file
"""
...
Docformatter is running via pre-commit
with this config:
- repo: https://github.com/myint/docformatter
rev: v1.7.5
hooks:
- id: docformatter
args: ["--in-place", "--wrap-summaries", "100"]
fin swimmer
huonw commented
Another example:
def f() -> None:
"""xx.
:param a: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb s3://cccc.
"""
Running docformatter
1.7.5 with default settings on that file gives this diff:
--- before//tmp/docformatter-duplicate.py
+++ after//tmp/docformatter-duplicate.py
@@ -1,5 +1,8 @@
def f() -> None:
"""xx.
- :param b: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb s3://cccc.
+ :param b: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ s3://cccc.
+ :param b: bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
+ s3://cccc.
"""
Things that seem to have to be true or this doesn't reproduce:
- first line has to have at least two characters, i.e.
x.
alone stops the duplicate - the text for the parameter has to be long enough for it to split across multiple lines, e.g. when it is
:param a: bb s3://cc
it fits on one line and there's no duplicate - the URL has to have a "known" URL scheme, e.g. using
yy://
stops the duplicate, buthttp://
has the duplicate