commit 758d431d6ec51a7821444acf20e138cf0c952d2e parent 3aa3b1445ecba0660b12b59ca88da32614a93c66 Author: Yuval Langer <yuvallangerontheroad@gmail.com> Date: Sun, 12 Dec 2021 18:25:59 +0200 Put things in explicit if-then-else branches, not implicit branches. Diffstat:
M | clipboard_speaker/clipboard_speaker.py | | | 11 | +++++------ |
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/clipboard_speaker/clipboard_speaker.py b/clipboard_speaker/clipboard_speaker.py @@ -14,16 +14,15 @@ WORDS_PER_MINUTE_PATH = CLIPBOARD_SPEAKER_PATH / "words-per-minute" def get_words_per_minute() -> str: - if not WORDS_PER_MINUTE_PATH.exists(): + if WORDS_PER_MINUTE_PATH.exists(): + with WORDS_PER_MINUTE_PATH.open("r") as words_per_minute_file: + words_per_minute = words_per_minute_file.read().strip() + return words_per_minute + else: with WORDS_PER_MINUTE_PATH.open("w") as words_per_minute_file: words_per_minute_file.write(DEFAULT_WORDS_PER_MINUTE) return DEFAULT_WORDS_PER_MINUTE - with WORDS_PER_MINUTE_PATH.open("r") as words_per_minute_file: - words_per_minute = words_per_minute_file.read().strip() - - return words_per_minute - def main() -> None: if not CLIPBOARD_SPEAKER_PATH.exists():