Docformatter inappropriately removes newline between classes
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 66/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- python
调研方向
Start by reproducing the report with the minimal Annotated class examples and docformatter 1.7.8, then trace the formatter’s handling of attribute docstrings and blank lines between classes. Compare the examples with and without a following method to narrow down the case. Done when formatting preserves the blank line between classes consistently with Black and the reported pre-commit deadlock is resolved.
由索引模型根据 Issue 内容生成。
描述
I am currently experiencing a pre-commit deadlock between Black and Docformatter , but only in a very specific case.
Consider the following:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, dict(something=1)]
"""Value that makes the parameter visible."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
Docformatter is removing a newline from in between the docstring for the equals property and the TransformParameter class, causing a deadlock in pre-commit because black puts two blank lines between classes.
This appears to only affect classes that use Annotated, and only if one of the parameters to Annotated contains a callable at any point with a keyword argument. The property must also not be followed by any methods. For example, this has the same bug:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
But this does not:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
def function(self):
"""Does a thing."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
I also found that in this scenario, it removes the newline between the classes:
from typing import Annotated, Any
class VisibleWhen:
"""Describe the condition that controls a parameter's visibility."""
equals: Annotated[Any, {"something": dict(something=1)}]
"""Value that makes the parameter visible."""
prop: Any
"""A description of the property."""
class TransformParameter:
"""Define an input parameter accepted by a transform."""
Versions and Config
I am using docformatter version 1.7.8. Below are my settings for both Black and Docformatter:
[tool.docformatter]
recursive = true
blank = true
black = true
in-place = true
[tool.black]
unstable = true
enable-unstable-feature = ["string_processing"]
- 主要语言
- Python
- 星标
- 600
- 派生
- 107
- 平均合并
- 22 小时 15 分钟
- 30 天内合并 PR
- 12
环境准备
这个项目没有提供开发容器、Dockerfile 或贡献指南,环境需要你自己搭建:先看它的 README,通用步骤见我们的新手贡献指南。
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
PyCQA/docformatter 的其他 Issue
-
`--docstring-length` removes blank line after docstrings it doesn't format (ping-pong with ruff format / Black)可能已有人在做 @RClaudiuM 于 1 天前认领。 未关闭fresh
难度 3/5 1-2 天 新手友好度 68/100
PyCQA/docformatter#420 ·
维护者通常 1 天内回复
-
docformatter fix does not consider parameters for added newlines可能重新可做 @AtharvRG 于 25 天前认领,目前没有进行中的 PR。 未关闭fresh
难度 3/5 1-2 天 新手友好度 68/100
PyCQA/docformatter#408 · 1 条评论 ·
维护者通常 1 天内回复
-
BUG: Inconsistent behavior between `docformatter` and `black`可能重新可做 @AtharvRG 于 25 天前认领,目前没有进行中的 PR。 未关闭fresh
难度 3/5 1-2 天 新手友好度 58/100
PyCQA/docformatter#399 · 1 条评论 ·
维护者通常 1 天内回复
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parentheses可能重新可做 @adityaanikam 于 106 天前认领,目前没有进行中的 PR。 未关闭C: convention P: bug U: high
难度 3/5 1-2 天 新手友好度 74/100
PyCQA/docformatter#367 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its value未关闭C: convention P: bug U: high
难度 3/5 1-2 天 新手友好度 72/100
PyCQA/docformatter#366 · 1 条评论 · 1 个 reaction ·
维护者通常 1 天内回复
查看 PyCQA/docformatter 的全部 Issue
相似的 Issue
-
bug
难度 1/5 1 小时以内 新手友好度 85/100
NatLabRockies/openstudio-mcp#286 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 78/100
-
bug
难度 2/5 1-3 小时 新手友好度 65/100
intersystems/ipm#1338 ·
维护者通常 1 天内回复
-
separate_packages splits imports from the same explicitly configured package可能已有人在做 @rahul05ranjan 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 2 天内回复
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definition未关闭v1
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复