From 8dcba06b28653ac8ee2bb1f1f9d05a66e5a0cefe Mon Sep 17 00:00:00 2001 From: Bonu Krishna Chaitanya Date: Sat, 6 Sep 2025 10:42:50 +0530 Subject: [PATCH 1/4] fix wrong indent for docstrings in IDLE --- Lib/idlelib/editor.py | 5 +---- Lib/idlelib/idle_test/test_editor.py | 4 ++-- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index b4d6d25871bcf4..f1cb8009d1c7a9 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1456,10 +1456,7 @@ def newline_and_indent_event(self, event): c = y.get_continuation_type() if c != pyparse.C_NONE: # The current statement hasn't ended yet. - if c == pyparse.C_STRING_FIRST_LINE: - # After the first line of a string do not indent at all. - pass - elif c == pyparse.C_STRING_NEXT_LINES: + if c == pyparse.C_STRING_FIRST_LINE or c == pyparse.C_STRING_NEXT_LINES: # Inside a string which started before this line; # just mimic the current indent. text.insert("insert", indent, self.user_input_insert_tags) diff --git a/Lib/idlelib/idle_test/test_editor.py b/Lib/idlelib/idle_test/test_editor.py index 0dfe2f3c58befa..fa0eeca0c09603 100644 --- a/Lib/idlelib/idle_test/test_editor.py +++ b/Lib/idlelib/idle_test/test_editor.py @@ -140,9 +140,9 @@ def test_indent_and_newline_event(self): ' def f1(self, a, b):', ' def f1(self,\n a, b):\n', '1.15'), - TestInfo('Inside string with one line - no indent.', + TestInfo('Inside string with one line.', ' """Docstring."""', - ' """Docstring.\n"""\n', + ' """Docstring.\n """\n', '1.15'), TestInfo('Inside string with more than one line.', ' """Docstring.\n Docstring Line 2"""', From d78984c1ecfd456dd61e890aa04556d8640803ec Mon Sep 17 00:00:00 2001 From: Bonu Krishna Chaitanya Date: Sat, 6 Sep 2025 10:51:52 +0530 Subject: [PATCH 2/4] format lines longer than 79chars --- Lib/idlelib/editor.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index f1cb8009d1c7a9..a51f8af3b3731d 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1456,7 +1456,10 @@ def newline_and_indent_event(self, event): c = y.get_continuation_type() if c != pyparse.C_NONE: # The current statement hasn't ended yet. - if c == pyparse.C_STRING_FIRST_LINE or c == pyparse.C_STRING_NEXT_LINES: + if ( + c == pyparse.C_STRING_FIRST_LINE + or c == pyparse.C_STRING_NEXT_LINES + ): # Inside a string which started before this line; # just mimic the current indent. text.insert("insert", indent, self.user_input_insert_tags) From b54bd41180c14c748fa5cc6d726c4d553df23777 Mon Sep 17 00:00:00 2001 From: "blurb-it[bot]" <43283697+blurb-it[bot]@users.noreply.github.com> Date: Sat, 6 Sep 2025 06:01:46 +0000 Subject: [PATCH 3/4] =?UTF-8?q?=F0=9F=93=9C=F0=9F=A4=96=20Added=20by=20blu?= =?UTF-8?q?rb=5Fit.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../next/IDLE/2025-09-06-06-01-45.gh-issue-138539.jBvls0.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/IDLE/2025-09-06-06-01-45.gh-issue-138539.jBvls0.rst diff --git a/Misc/NEWS.d/next/IDLE/2025-09-06-06-01-45.gh-issue-138539.jBvls0.rst b/Misc/NEWS.d/next/IDLE/2025-09-06-06-01-45.gh-issue-138539.jBvls0.rst new file mode 100644 index 00000000000000..b83c5669207311 --- /dev/null +++ b/Misc/NEWS.d/next/IDLE/2025-09-06-06-01-45.gh-issue-138539.jBvls0.rst @@ -0,0 +1 @@ +Fix wrong indent for docstrings From f65f36baf06761ed63bd1ecff3c71cfd8ae02ce2 Mon Sep 17 00:00:00 2001 From: Bonu Krishna Chaitanya Date: Sat, 6 Sep 2025 11:32:31 +0530 Subject: [PATCH 4/4] remove trailing whitespace --- Lib/idlelib/editor.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lib/idlelib/editor.py b/Lib/idlelib/editor.py index a51f8af3b3731d..193464f266cf84 100644 --- a/Lib/idlelib/editor.py +++ b/Lib/idlelib/editor.py @@ -1457,7 +1457,7 @@ def newline_and_indent_event(self, event): if c != pyparse.C_NONE: # The current statement hasn't ended yet. if ( - c == pyparse.C_STRING_FIRST_LINE + c == pyparse.C_STRING_FIRST_LINE or c == pyparse.C_STRING_NEXT_LINES ): # Inside a string which started before this line;