BUG: Inconsistent behavior between `docformatter` and `black`
Maintainers usually reply within 1 day
@AtharvRG is already working on this.
Since Oct 31, 2026.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 58/100
Research direction
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.
Written by the indexing model from the issue text.
Description
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
- Dominant language
- Python
- Stars
- 600
- Forks
- 107
- Avg merge
- 22h 15m
- Merged PRs (30d)
- 12
Getting set up
This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from PyCQA/docformatter
-
`--docstring-length` removes blank line after docstrings it doesn't format (ping-pong with ruff format / Black)Possibly taken @RClaudiuM claimed this 1 day ago. Openfresh
Difficulty 3/5 1-2 days Newbie friendliness 68/100
PyCQA/docformatter#420 ·
Maintainers usually reply within 1 day
-
fresh
Difficulty 3/5 1-2 days Newbie friendliness 66/100
PyCQA/docformatter#414 · 1 reaction ·
Maintainers usually reply within 1 day
-
docformatter fix does not consider parameters for added newlinesMay be free again @AtharvRG claimed this 25 days ago, and no pull request is open. Openfresh
Difficulty 3/5 1-2 days Newbie friendliness 68/100
PyCQA/docformatter#408 · 1 comment ·
Maintainers usually reply within 1 day
-
1.7.8 crashes with a tokenize ValueError on a multi-line f-string inside parenthesesMay be free again @adityaanikam claimed this 106 days ago, and no pull request is open. OpenC: convention P: bug U: high
Difficulty 3/5 1-2 days Newbie friendliness 74/100
PyCQA/docformatter#367 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
-
1.7.8 rewrites the contents of a non-docstring triple-quoted string, silently changing its valueOpenC: convention P: bug U: high
Difficulty 3/5 1-2 days Newbie friendliness 72/100
PyCQA/docformatter#366 · 1 comment · 1 reaction ·
Maintainers usually reply within 1 day
All issues in PyCQA/docformatter
Similar issues
-
bug
Difficulty 1/5 Under an hour Newbie friendliness 85/100
NatLabRockies/openstudio-mcp#286 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
intersystems/ipm#1338 ·
Maintainers usually reply within 1 day
-
separate_packages splits imports from the same explicitly configured packagePossibly taken @rahul05ranjan claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
The v0-through-v1 path derives ShutdownDuration its own way, silently overriding a user's definitionOpenv1
Difficulty 2/5 1-3 hours Newbie friendliness 62/100
Maintainers usually reply within 1 day