Docformatter inappropriately removes newline between classes
Maintainer thường phản hồi trong vòng 1 ngày
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 66/100
- Loại issue
- Lỗi
- Độ rõ ràng
- Đặc tả rõ ràng
- Mức độ hoạt động
- Sôi nổi
- Công nghệ
- python
- Lĩnh vực
- developer-experience, tooling
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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"]
- Ngôn ngữ chính
- Python
- Star
- 600
- Fork
- 107
- Merge trung bình
- 22 giờ 15 phút
- Pull request đã merge (30 ngày)
- 12
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của PyCQA/docformatter
-
`--docstring-length` removes blank line after docstrings it doesn't format (ping-pong with ruff format / Black)Có thể đã có người làm @RClaudiuM đã nhận 1 ngày trước. Đang mởfresh
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PyCQA/docformatter#420 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
docformatter fix does not consider parameters for added newlinesCó thể làm lại được @AtharvRG đã nhận 25 ngày trước và không có pull request nào đang mở. Đang mởfresh
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 68/100
PyCQA/docformatter#408 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
BUG: Inconsistent behavior between `docformatter` and `black`Có thể làm lại được @AtharvRG đã nhận 25 ngày trước và không có pull request nào đang mở. Đang mởfresh
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 58/100
PyCQA/docformatter#399 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesCó thể làm lại được @adityaanikam đã nhận 106 ngày trước và không có pull request nào đang mở. Đang mởC: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 74/100
PyCQA/docformatter#367 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueĐang mởC: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 72/100
PyCQA/docformatter#366 · 1 bình luận · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
Tất cả issue của PyCQA/docformatter
Issue tương tự
-
bug
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
intersystems/ipm#1338 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
separate_packages splits imports from the same explicitly configured packageCó thể đã có người làm @rahul05ranjan đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 2 ngày
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionĐang mởv1
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
Maintainer thường phản hồi trong vòng 1 ngày