FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-111201: fix auto-indent in pyrepl for muliple pound comments by wiggin15 · Pull Request #123196 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (2) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Lib/_pyrepl/readline.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ def _should_auto_indent(buffer: list[str], pos: int) -> bool:
while pos > 0:
pos -= 1
if last_char is None:
if buffer[pos] not in " \t\n": # ignore whitespaces
if buffer[pos] not in " \t\n#": # ignore whitespaces and comments
last_char = buffer[pos]
else:
# even if we found a non-whitespace character before
Expand Down
18 changes: 18 additions & 0 deletions Lib/test/test_pyrepl/test_pyrepl.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,24 @@ def test_auto_indent_with_comment(self):
output = multiline_input(reader)
self.assertEqual(output, output_code)

def test_auto_indent_with_multicomment(self):
# fmt: off
events = code_to_events(
"def f(): ## foo\n"
"pass\n\n"
)

output_code = (
"def f(): ## foo\n"
" pass\n"
" "
)
# fmt: on

reader = self.prepare_reader(events)
output = multiline_input(reader)
self.assertEqual(output, output_code)

def test_auto_indent_ignore_comments(self):
# fmt: off
events = code_to_events(
Expand Down

Back | FazBrowse Home | New Git URL