From eb8af1d93041040d19ab05924d4c174944c38d54 Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Fri, 16 Dec 2022 16:40:53 +0100 Subject: [PATCH 1/3] Flush stdout when asking word fix --- codespell_lib/_codespell.py | 1 + 1 file changed, 1 insertion(+) diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index c7ce66be1b..e91362b177 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -694,6 +694,7 @@ def ask_for_word_fix( fixword = fix_case(wrongword, misspelling.data) while not r: print(f"{line}\t{wrongword} ==> {fixword} (Y/n) ", end="") + sys.stdout.flush() r = sys.stdin.readline().strip().upper() if not r: r = "Y" From f2b71836c9ac92896520443485b09273ec8cbc22 Mon Sep 17 00:00:00 2001 From: Eric Larson Date: Fri, 16 Dec 2022 11:01:28 -0500 Subject: [PATCH 2/3] Update codespell_lib/_codespell.py --- codespell_lib/_codespell.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index e91362b177..f75aba772a 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -693,8 +693,8 @@ def ask_for_word_fix( r = "" fixword = fix_case(wrongword, misspelling.data) while not r: - print(f"{line}\t{wrongword} ==> {fixword} (Y/n) ", end="") - sys.stdout.flush() + print(f"{line}\t{wrongword} ==> {fixword} (Y/n) ", end="", + flush=True) r = sys.stdin.readline().strip().upper() if not r: r = "Y" From d91787f5fcc4d4312f69b46350a7a868de14358f Mon Sep 17 00:00:00 2001 From: Adrien Berchet Date: Fri, 16 Dec 2022 17:26:55 +0100 Subject: [PATCH 3/3] Use flush for missplelling with a reason --- codespell_lib/_codespell.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/codespell_lib/_codespell.py b/codespell_lib/_codespell.py index f75aba772a..cd6845484f 100644 --- a/codespell_lib/_codespell.py +++ b/codespell_lib/_codespell.py @@ -693,8 +693,7 @@ def ask_for_word_fix( r = "" fixword = fix_case(wrongword, misspelling.data) while not r: - print(f"{line}\t{wrongword} ==> {fixword} (Y/n) ", end="", - flush=True) + print(f"{line}\t{wrongword} ==> {fixword} (Y/n) ", end="", flush=True) r = sys.stdin.readline().strip().upper() if not r: r = "Y" @@ -716,8 +715,7 @@ def ask_for_word_fix( for i, o in enumerate(opt): fixword = fix_case(wrongword, o) print(" %d) %s" % (i, fixword), end="") - print(": ", end="") - sys.stdout.flush() + print(": ", end="", flush=True) n = sys.stdin.readline().strip() if not n: