Skip to content

Fix: In src/docformatter/classify.py, is_attribute_docstring() previously... - #375

Open
M001N wants to merge 2 commits into
PyCQA:masterfrom
M001N:oss-engine/f2057e57-063e80f8
Open

Fix: In src/docformatter/classify.py, is_attribute_docstring() previously...#375
M001N wants to merge 2 commits into
PyCQA:masterfrom
M001N:oss-engine/f2057e57-063e80f8

Conversation

@M001N

@M001N M001N commented Aug 16, 2026

Copy link
Copy Markdown

Summary

No production code change was needed: the fix for this exact defect (bracket-depth check in is_attribute_docstring/_is_inside_brackets) is already present in this worktree's history via PR #364. I added a dedicated regression test reproducing issue #366's exact snippet to tests/_data/string_files/do_format_code.toml (case issue_366_triple_quote_in_parens_not_docstring, source==expected, i.e. unchanged) and wired it into the existing parametrized test in tests/formatter/test_do_format_code.py, following that file's established pattern (TOML-backed source/expected pairs, one entry per issue).

Problem

PyCQA/docformatter issue reference: #366

Root Cause

In src/docformatter/classify.py, is_attribute_docstring() previously treated any triple-quoted string preceded by an '=' as an attribute docstring even when the string sits inside an unclosed bracket (e.g. a parenthesized concatenation), causing docformatter to reformat its literal contents. This was already fixed upstream in commit e8901bc 'fix: do not treat a bracketed string literal as an attribute docstring (#364)', which added the _is_inside_brackets() guard (classify.py lines 202-204, 207-232) that this worktree's HEAD already includes (it is an ancestor of the current branch tip). Reproducing the issue's exact snippet against the current code shows the output is byte-identical to the input -- the bug does not manifest here.

Testing

PASS -- 73 passed, 1 deselected (the pre-existing unrelated preserve_line_ending failure, excluded per instructions); the new issue_366 case passes, confirming the string is left byte-identical.

Related Issue

#366

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant