From 117f952369cc1c49091f86fd390cfeb93e079a9a Mon Sep 17 00:00:00 2001 From: dataflow-solutions-sk Date: Sun, 16 Aug 2026 16:37:53 +0200 Subject: [PATCH 1/2] test: add regression test for issue #366 (triple-quoted string in parens misclassified as docstring) --- exitcode.txt | 1 + out.txt | 0 out2.txt | 0 out3.txt | 0 out4.txt | 0 out5.txt | 11 +++++++ outrepro.txt | 15 +++++++++ outrepro2.txt | 10 ++++++ repro.py | 7 +++++ testfull.txt | 22 ++++++++++++++ testout.txt | 32 ++++++++++++++++++++ tests/_data/string_files/do_format_code.toml | 4 +++ tests/formatter/test_do_format_code.py | 1 + 13 files changed, 103 insertions(+) create mode 100644 exitcode.txt create mode 100644 out.txt create mode 100644 out2.txt create mode 100644 out3.txt create mode 100644 out4.txt create mode 100644 out5.txt create mode 100644 outrepro.txt create mode 100644 outrepro2.txt create mode 100644 repro.py create mode 100644 testfull.txt create mode 100644 testout.txt diff --git a/exitcode.txt b/exitcode.txt new file mode 100644 index 00000000..4ecb8f0c --- /dev/null +++ b/exitcode.txt @@ -0,0 +1 @@ +EXIT=3 diff --git a/out.txt b/out.txt new file mode 100644 index 00000000..e69de29b diff --git a/out2.txt b/out2.txt new file mode 100644 index 00000000..e69de29b diff --git a/out3.txt b/out3.txt new file mode 100644 index 00000000..e69de29b diff --git a/out4.txt b/out4.txt new file mode 100644 index 00000000..e69de29b diff --git a/out5.txt b/out5.txt new file mode 100644 index 00000000..94791e22 --- /dev/null +++ b/out5.txt @@ -0,0 +1,11 @@ +python : Traceback (most recent call last): +At line:1 char:420 ++ ... 80f8-430d-467b-9c88-6e6b75088c2e; $env:PYTHONPATH="src"; python -c @' ++ ~~~~~~~~~~~~ + + CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException + + FullyQualifiedErrorId : NativeCommandError + + File "", line 3, in + src = X + ^ +NameError: name 'X' is not defined diff --git a/outrepro.txt b/outrepro.txt new file mode 100644 index 00000000..bbedcf96 --- /dev/null +++ b/outrepro.txt @@ -0,0 +1,15 @@ +python : Traceback (most recent call last): +At line:1 char:420 ++ ... PATH="src"; python "C:\Users\asus\AppData\Local\Temp\claude\C--Users- ... ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException + + FullyQualifiedErrorId : NativeCommandError + + File "C:\Users\asus\AppData\Local\Temp\claude\C--Users-asus-AppData-Local-Temp-oss-engine-worktrees-063e80f8-430d-467 +b-9c88-6e6b75088c2e\d8ff54b4-0541-481f-a59d-3a372f13dff7\scratchpad\repro.py", line 14, in + out = uut._do_format_code(src) + File "C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\src\docformatter\for +mat.py", line 905, in _do_format_code + if self.args.line_range is not None: + ^^^^^^^^^^^^^^^^^^^^ +AttributeError: 'list' object has no attribute 'line_range' diff --git a/outrepro2.txt b/outrepro2.txt new file mode 100644 index 00000000..08bb84d1 --- /dev/null +++ b/outrepro2.txt @@ -0,0 +1,10 @@ +SAME +---OUT--- +X = ( + """#!/bin/bash +# Ends here. +# A second line. +_real=""" + + "y" +) + diff --git a/repro.py b/repro.py new file mode 100644 index 00000000..3b57f662 --- /dev/null +++ b/repro.py @@ -0,0 +1,7 @@ +X = ( + """#!/bin/bash +# Ends here. +# A second line. +_real=""" + + "y" +) diff --git a/testfull.txt b/testfull.txt new file mode 100644 index 00000000..a291c340 --- /dev/null +++ b/testfull.txt @@ -0,0 +1,22 @@ +python : C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\__init__.py:113: RequestsDepe +ndencyWarning: urllib3 (2.6.3) or chardet (7.3.0)/charset_normalizer (3.4.4) doesn't match a supported version! +At line:1 char:420 ++ ... PATH="src"; python -m pytest tests/formatter/test_do_format_code.py - ... ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo : NotSpecified: (C:\Users\asus\A...ported version!:String) [], RemoteException + + FullyQualifiedErrorId : NativeCommandError + + warnings.warn( +........................................................................ [ 98%] +. [100%] +============================== warnings summary =============================== +tests\formatter\test_do_format_code.py:55 + C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:55: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html + @pytest.mark.order(7) + +tests\formatter\test_do_format_code.py:165 + C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:165: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html + @pytest.mark.order(7) + +-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html +73 passed, 1 deselected, 2 warnings in 0.16s diff --git a/testout.txt b/testout.txt new file mode 100644 index 00000000..3b8406d3 --- /dev/null +++ b/testout.txt @@ -0,0 +1,32 @@ +python : C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\__init__.py:113: RequestsDepe +ndencyWarning: urllib3 (2.6.3) or chardet (7.3.0)/charset_normalizer (3.4.4) doesn't match a supported version! +At line:1 char:420 ++ ... PATH="src"; python -m pytest "tests/formatter/test_do_format_code.py: ... ++ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + CategoryInfo : NotSpecified: (C:\Users\asus\A...ported version!:String) [], RemoteException + + FullyQualifiedErrorId : NativeCommandError + + warnings.warn( +============================= test session starts ============================= +platform win32 -- Python 3.14.3, pytest-9.1.1, pluggy-1.6.0 -- C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\python.exe +cachedir: .pytest_cache +Using --randomly-seed=1654985140 +rootdir: C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e +configfile: pyproject.toml +plugins: anyio-4.12.1, langsmith-0.7.14, asyncio-1.4.0, cov-7.1.0, datadir-1.8.0, env-1.7.0, mock-3.15.1, randomly-4.1.0, regressions-2.11.0, xdist-3.8.0 +asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function +collecting ... collected 73 items / 72 deselected / 1 selected + +tests/formatter/test_do_format_code.py::test_do_format_code[issue_366_triple_quote_in_parens_not_docstring-args72] PASSED [100%] + +============================== warnings summary =============================== +tests\formatter\test_do_format_code.py:55 + C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:55: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html + @pytest.mark.order(7) + +tests\formatter\test_do_format_code.py:165 + C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:165: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html + @pytest.mark.order(7) + +-- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html +================ 1 passed, 72 deselected, 2 warnings in 0.06s ================= diff --git a/tests/_data/string_files/do_format_code.toml b/tests/_data/string_files/do_format_code.toml index d652a15c..62933c5c 100644 --- a/tests/_data/string_files/do_format_code.toml +++ b/tests/_data/string_files/do_format_code.toml @@ -1260,3 +1260,7 @@ expected="def foo():\n \"\"\"Summary.\"\"\"\n x = 1\n # next line has 4 [issue_360_no_trailing_newline] source="def foo():\n \"\"\"\n Hello foo.\n \"\"\"\n x = 1" expected="def foo():\n \"\"\"Hello foo.\"\"\"\n x = 1" + +[issue_366_triple_quote_in_parens_not_docstring] +source="X = (\n \"\"\"#!/bin/bash\n# Ends here.\n# A second line.\n_real=\"\"\"\n + \"y\"\n)\n" +expected="X = (\n \"\"\"#!/bin/bash\n# Ends here.\n# A second line.\n_real=\"\"\"\n + \"y\"\n)\n" diff --git a/tests/formatter/test_do_format_code.py b/tests/formatter/test_do_format_code.py index 037ace10..b0d75ddd 100644 --- a/tests/formatter/test_do_format_code.py +++ b/tests/formatter/test_do_format_code.py @@ -143,6 +143,7 @@ ("issue_331_black_module_docstring", ["--black", ""]), ("issue_355", NO_ARGS), ("issue_360_no_trailing_newline", NO_ARGS), + ("issue_366_triple_quote_in_parens_not_docstring", NO_ARGS), ], ) def test_do_format_code(test_key, test_args, args): From bc45e22559726cadd13dcf3aa1e0b475b8db2050 Mon Sep 17 00:00:00 2001 From: dataflow-solutions-sk Date: Sun, 16 Aug 2026 16:37:58 +0200 Subject: [PATCH 2/2] chore: remove stray scratch files --- exitcode.txt | 1 - out.txt | 0 out2.txt | 0 out3.txt | 0 out4.txt | 0 out5.txt | 11 ----------- outrepro.txt | 15 --------------- outrepro2.txt | 10 ---------- repro.py | 7 ------- testfull.txt | 22 ---------------------- testout.txt | 32 -------------------------------- 11 files changed, 98 deletions(-) delete mode 100644 exitcode.txt delete mode 100644 out.txt delete mode 100644 out2.txt delete mode 100644 out3.txt delete mode 100644 out4.txt delete mode 100644 out5.txt delete mode 100644 outrepro.txt delete mode 100644 outrepro2.txt delete mode 100644 repro.py delete mode 100644 testfull.txt delete mode 100644 testout.txt diff --git a/exitcode.txt b/exitcode.txt deleted file mode 100644 index 4ecb8f0c..00000000 --- a/exitcode.txt +++ /dev/null @@ -1 +0,0 @@ -EXIT=3 diff --git a/out.txt b/out.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/out2.txt b/out2.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/out3.txt b/out3.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/out4.txt b/out4.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/out5.txt b/out5.txt deleted file mode 100644 index 94791e22..00000000 --- a/out5.txt +++ /dev/null @@ -1,11 +0,0 @@ -python : Traceback (most recent call last): -At line:1 char:420 -+ ... 80f8-430d-467b-9c88-6e6b75088c2e; $env:PYTHONPATH="src"; python -c @' -+ ~~~~~~~~~~~~ - + CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException - + FullyQualifiedErrorId : NativeCommandError - - File "", line 3, in - src = X - ^ -NameError: name 'X' is not defined diff --git a/outrepro.txt b/outrepro.txt deleted file mode 100644 index bbedcf96..00000000 --- a/outrepro.txt +++ /dev/null @@ -1,15 +0,0 @@ -python : Traceback (most recent call last): -At line:1 char:420 -+ ... PATH="src"; python "C:\Users\asus\AppData\Local\Temp\claude\C--Users- ... -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : NotSpecified: (Traceback (most recent call last)::String) [], RemoteException - + FullyQualifiedErrorId : NativeCommandError - - File "C:\Users\asus\AppData\Local\Temp\claude\C--Users-asus-AppData-Local-Temp-oss-engine-worktrees-063e80f8-430d-467 -b-9c88-6e6b75088c2e\d8ff54b4-0541-481f-a59d-3a372f13dff7\scratchpad\repro.py", line 14, in - out = uut._do_format_code(src) - File "C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\src\docformatter\for -mat.py", line 905, in _do_format_code - if self.args.line_range is not None: - ^^^^^^^^^^^^^^^^^^^^ -AttributeError: 'list' object has no attribute 'line_range' diff --git a/outrepro2.txt b/outrepro2.txt deleted file mode 100644 index 08bb84d1..00000000 --- a/outrepro2.txt +++ /dev/null @@ -1,10 +0,0 @@ -SAME ----OUT--- -X = ( - """#!/bin/bash -# Ends here. -# A second line. -_real=""" - + "y" -) - diff --git a/repro.py b/repro.py deleted file mode 100644 index 3b57f662..00000000 --- a/repro.py +++ /dev/null @@ -1,7 +0,0 @@ -X = ( - """#!/bin/bash -# Ends here. -# A second line. -_real=""" - + "y" -) diff --git a/testfull.txt b/testfull.txt deleted file mode 100644 index a291c340..00000000 --- a/testfull.txt +++ /dev/null @@ -1,22 +0,0 @@ -python : C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\__init__.py:113: RequestsDepe -ndencyWarning: urllib3 (2.6.3) or chardet (7.3.0)/charset_normalizer (3.4.4) doesn't match a supported version! -At line:1 char:420 -+ ... PATH="src"; python -m pytest tests/formatter/test_do_format_code.py - ... -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : NotSpecified: (C:\Users\asus\A...ported version!:String) [], RemoteException - + FullyQualifiedErrorId : NativeCommandError - - warnings.warn( -........................................................................ [ 98%] -. [100%] -============================== warnings summary =============================== -tests\formatter\test_do_format_code.py:55 - C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:55: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html - @pytest.mark.order(7) - -tests\formatter\test_do_format_code.py:165 - C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:165: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html - @pytest.mark.order(7) - --- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html -73 passed, 1 deselected, 2 warnings in 0.16s diff --git a/testout.txt b/testout.txt deleted file mode 100644 index 3b8406d3..00000000 --- a/testout.txt +++ /dev/null @@ -1,32 +0,0 @@ -python : C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\Lib\site-packages\requests\__init__.py:113: RequestsDepe -ndencyWarning: urllib3 (2.6.3) or chardet (7.3.0)/charset_normalizer (3.4.4) doesn't match a supported version! -At line:1 char:420 -+ ... PATH="src"; python -m pytest "tests/formatter/test_do_format_code.py: ... -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : NotSpecified: (C:\Users\asus\A...ported version!:String) [], RemoteException - + FullyQualifiedErrorId : NativeCommandError - - warnings.warn( -============================= test session starts ============================= -platform win32 -- Python 3.14.3, pytest-9.1.1, pluggy-1.6.0 -- C:\Users\asus\AppData\Local\Python\pythoncore-3.14-64\python.exe -cachedir: .pytest_cache -Using --randomly-seed=1654985140 -rootdir: C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e -configfile: pyproject.toml -plugins: anyio-4.12.1, langsmith-0.7.14, asyncio-1.4.0, cov-7.1.0, datadir-1.8.0, env-1.7.0, mock-3.15.1, randomly-4.1.0, regressions-2.11.0, xdist-3.8.0 -asyncio: mode=Mode.STRICT, debug=False, asyncio_default_fixture_loop_scope=None, asyncio_default_test_loop_scope=function -collecting ... collected 73 items / 72 deselected / 1 selected - -tests/formatter/test_do_format_code.py::test_do_format_code[issue_366_triple_quote_in_parens_not_docstring-args72] PASSED [100%] - -============================== warnings summary =============================== -tests\formatter\test_do_format_code.py:55 - C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:55: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html - @pytest.mark.order(7) - -tests\formatter\test_do_format_code.py:165 - C:\Users\asus\AppData\Local\Temp\oss_engine_worktrees\063e80f8-430d-467b-9c88-6e6b75088c2e\tests\formatter\test_do_format_code.py:165: PytestUnknownMarkWarning: Unknown pytest.mark.order - is this a typo? You can register custom marks to avoid this warning - for details, see https://docs.pytest.org/en/stable/how-to/mark.html - @pytest.mark.order(7) - --- Docs: https://docs.pytest.org/en/stable/how-to/capture-warnings.html -================ 1 passed, 72 deselected, 2 warnings in 0.06s =================