BUG: Inconsistent behavior between `docformatter` and `black`
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
- 58/100
Hướng nghiên cứu
The report shows disagreements across six Python files and includes Black's diffs, but does not identify docformatter's implementation or tests. Start by reproducing with the reported docformatter and Black versions, then inspect how docformatter formats these cases and the project's formatter tests. Done when the reported cases produce output accepted by both tools.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Env
Installed tools :
python --version
Python 3.12.7
docformatter --version
docformatter 1.7.8
black --version
black, 26.10.1 (compiled: yes)
Python (CPython) 3.12.7
pyproject.toml :
[tool.docformatter]
wrap-summaries = 88 # --black
wrap-descriptions = 88 # --black
pre-summary-newline = true
close-quotes-on-newline = true
[tool.black]
line-length = 88
target-version = ['py312']
extend-exclude = '''
/(
assets
)/
'''
Problem
Executions 1 (All code has been formatted by black):
docformatter --check --recursive --black onvif tests docs
docs\hooks\misc.py
onvif\operator.py
onvif\cli\helpers\products.py
tests\cli\test_cli_helper_wsdl_parser.py
tests\cli\test_cli_interactive_service.py
tests\utilities\test_exceptions.py
black --check .
All done! ✨ 🍰 ✨
179 files would be left unchanged.
For docformatter, code styles that have already been formatted by black are considered to have failed or to be non-compliant with the standards.
Executions 2 (All code has been formatted by docformatter):
docformatter --recursive --black --in-place onvif tests docs
black --check .
would reformat F:\Forks\onvif-python\docs\hooks\misc.py
would reformat F:\Forks\onvif-python\onvif\cli\helpers\products.py
would reformat F:\Forks\onvif-python\onvif\operator.py
would reformat F:\Forks\onvif-python\tests\utilities\test_exceptions.py
would reformat F:\Forks\onvif-python\tests\cli\test_cli_helper_wsdl_parser.py
would reformat F:\Forks\onvif-python\tests\cli\test_cli_interactive_service.py
Oh no! 💥 💔 💥
6 files would be reformatted, 173 files would be left unchanged.
Once all docstrings and code have been formatted by docformatter, now black then considers them unformatted.
Diff for debugging
black --diff docs/hooks/misc.py onvif/operator.py onvif/cli/helpers/products.py tests/utilities/test_exceptions.py tests/cli/test_cli_helper_wsdl_parser.py tests/cli/test_cli_interactive_service.py
--- docs\hooks\misc.py 2026-10-21 19:46:44.117053+00:00
+++ docs\hooks\misc.py 2026-10-21 19:48:41.899862+00:00
@@ -1,6 +1,7 @@
"""Misc Mkdocs hooks."""
+
def on_page_content(html, page, config, files): # pylint: disable=unused-argument
"""Exclude mkdocstrings source blocks from Material search."""
return html.replace(
'<details class="mkdocstrings-source">',
would reformat docs\hooks\misc.py
--- onvif\cli\helpers\products.py 2026-10-21 19:46:44.299099+00:00
+++ onvif\cli\helpers\products.py 2026-10-21 19:48:42.029537+00:00
@@ -24,21 +24,21 @@
# Get the database path relative to the script location
db_path = Path(__file__).resolve().parent.parent.parent / "db" / "products.db"
if not os.path.exists(db_path):
print(
- f"{colorize('Error:', 'red')} " f"Products database not found at {db_path}"
+ f"{colorize('Error:', 'red')} " f"Products database not found at {db_path}"
)
sys.exit(1)
# Validate pagination parameters
if page < 1:
print(f"{colorize('Error:', 'red')} Page number must be 1 or greater")
sys.exit(1)
if per_page < 1 or per_page > 100:
- print(f"{colorize('Error:', 'red')} " "Per-page must be between 1 and 100")
+ print(f"{colorize('Error:', 'red')} " "Per-page must be between 1 and 100")
sys.exit(1)
try:
conn = sqlite3.connect(db_path)
cursor = conn.cursor()
would reformat onvif\cli\helpers\products.py
--- onvif\operator.py 2026-10-21 19:46:44.226079+00:00
+++ onvif\operator.py 2026-10-21 19:48:42.044543+00:00
@@ -87,10 +87,11 @@
:material-alert-circle:{ .danger } Requires disk I/O and a writable cache directory
!!! bug "Use case" Production applications, CLI tools, and environments where
WSDL/XSD caching should persist across restarts.
"""
+
class ONVIFOperator:
"""
<!-- md:version 0.0.1 --> <!-- md:internal -->
would reformat onvif\operator.py
--- tests\utilities\test_exceptions.py 2026-10-21 19:46:45.729424+00:00
+++ tests\utilities\test_exceptions.py 2026-10-21 19:48:42.071102+00:00
@@ -34,22 +34,18 @@
"""exceptions."""
class RequestException(Exception):
"""RequestException."""
-
class ConnectionError(RequestException):
"""ConnectionError."""
-
class Timeout(RequestException):
"""Timeout."""
-
class ReadTimeout(Timeout):
"""ReadTimeout."""
-
requests = MockRequestsModule() # type: ignore[assignment]
class TestONVIFOperationException:
would reformat tests\utilities\test_exceptions.py
--- tests\cli\test_cli_helper_wsdl_parser.py 2026-10-21 19:46:45.158408+00:00
+++ tests\cli\test_cli_helper_wsdl_parser.py 2026-10-21 19:48:42.138691+00:00
@@ -418,12 +418,11 @@
assert result == "Hello world from parser"
def test_handles_multiline_links(self):
"""Test converting links whose content spans multiple lines."""
- result = clean_documentation_html(\
- """
+ result = clean_documentation_html("""
<a href="https://example.com">
Example
</a>
""")
@@ -443,12 +442,11 @@
assert extract_documentation_text(element) == "Hello world"
def test_text_and_children(self):
"""Test extracting text before, inside, and after child elements."""
- element = etree.fromstring(\
- b"""
+ element = etree.fromstring(b"""
<documentation>
Before
<b>middle</b>
After
</documentation>
would reformat tests\cli\test_cli_helper_wsdl_parser.py
--- tests\cli\test_cli_interactive_service.py 2026-10-21 19:46:45.301377+00:00
+++ tests\cli\test_cli_interactive_service.py 2026-10-21 19:48:42.218530+00:00
@@ -734,11 +734,11 @@
{
"name": "Token",
"type": "string",
"minOccurs": "1",
"maxOccurs": "1",
- "documentation": ("First line.\n" "\n" "Second line."),
+ "documentation": ("First line.\n" "\n" "Second line."),
}
],
},
"output": None,
}
would reformat tests\cli\test_cli_interactive_service.py
- Ngôn ngữ chính
- Python
- Star
- 598
- Fork
- 97
- Merge trung bình
- 1 ngày 8 giờ
- Pull request đã merge (30 ngày)
- 11
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
-
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 74 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 ·
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 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C: stakeholder P: enhancement U: low
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 65/100
PyCQA/docformatter#346 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
C: convention P: bug U: high
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 48/100
PyCQA/docformatter#345 · 1 reaction ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Multiline summary is not split correctlyCó thể làm lại được Pull request cho issue này đã bị đóng mà không được merge. Đ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 55/100
PyCQA/docformatter#315 · 1 bình luận ·
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ự
-
good first issue infrastructure
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
kuznia-rdzeni/coreblocks#1135 ·
-
good first issue server
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 85/100
Maintainer thường phản hồi trong vòng 1 ngày
-
documentation priority: high
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
a-lex-s/mealie-telegram-bot#54 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
type/test
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
SaltedTan/virgil-language-server#218 ·
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 83/100
btclib-org/btclib-wallet#541 ·
Maintainer thường phản hồi trong vòng 1 ngày