From 48fee4fc92d30c5f4688c535fc315b2fd6f6b87b Mon Sep 17 00:00:00 2001 From: link2xt Date: Sat, 18 Feb 2023 11:31:07 +0000 Subject: [PATCH] python: replace "while 1" with "while True" This makes pyright recognize that the function never returns implicitly. --- python/src/deltachat/direct_imap.py | 4 ++-- python/src/deltachat/events.py | 16 ++++++++-------- python/src/deltachat/testplugin.py | 6 +++--- python/src/deltachat/tracker.py | 2 +- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/python/src/deltachat/direct_imap.py b/python/src/deltachat/direct_imap.py index 193924055..d95bd29ab 100644 --- a/python/src/deltachat/direct_imap.py +++ b/python/src/deltachat/direct_imap.py @@ -207,14 +207,14 @@ class IdleManager: return res def wait_for_new_message(self, timeout=None) -> bytes: - while 1: + while True: for item in self.check(timeout=timeout): if b"EXISTS" in item or b"RECENT" in item: return item def wait_for_seen(self, timeout=None) -> int: """Return first message with SEEN flag from a running idle-stream.""" - while 1: + while True: for item in self.check(timeout=timeout): if FETCH in item: self.log(str(item)) diff --git a/python/src/deltachat/events.py b/python/src/deltachat/events.py index d88876004..006095da0 100644 --- a/python/src/deltachat/events.py +++ b/python/src/deltachat/events.py @@ -108,7 +108,7 @@ class FFIEventTracker: return ev def iter_events(self, timeout=None, check_error=True): - while 1: + while True: yield self.get(timeout=timeout, check_error=check_error) def get_matching(self, event_name_regex, check_error=True, timeout=None): @@ -119,14 +119,14 @@ class FFIEventTracker: def get_info_contains(self, regex: str) -> FFIEvent: rex = re.compile(regex) - while 1: + while True: ev = self.get_matching("DC_EVENT_INFO") if rex.search(ev.data2): return ev def get_info_regex_groups(self, regex, check_error=True): rex = re.compile(regex) - while 1: + while True: ev = self.get_matching("DC_EVENT_INFO", check_error=check_error) m = rex.match(ev.data2) if m is not None: @@ -137,7 +137,7 @@ class FFIEventTracker: This only works reliably if the connectivity doesn't change again too quickly, otherwise we might miss it. """ - while 1: + while True: if self.account.get_connectivity() == connectivity: return self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") @@ -146,7 +146,7 @@ class FFIEventTracker: """Wait until the connectivity changes to `expected_next`. Fails the test if it changes to something else. """ - while 1: + while True: current = self.account.get_connectivity() if current == expected_next: return @@ -156,7 +156,7 @@ class FFIEventTracker: self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") def wait_for_all_work_done(self): - while 1: + while True: if self.account.all_work_done(): return self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") @@ -164,7 +164,7 @@ class FFIEventTracker: def ensure_event_not_queued(self, event_name_regex): __tracebackhide__ = True rex = re.compile(f"(?:{event_name_regex}).*") - while 1: + while True: try: ev = self._event_queue.get(False) except Empty: @@ -173,7 +173,7 @@ class FFIEventTracker: assert not rex.match(ev.name), f"event found {ev}" def wait_securejoin_inviter_progress(self, target): - while 1: + while True: event = self.get_matching("DC_EVENT_SECUREJOIN_INVITER_PROGRESS") if event.data2 >= target: print(f"** SECUREJOINT-INVITER PROGRESS {target}", self.account) diff --git a/python/src/deltachat/testplugin.py b/python/src/deltachat/testplugin.py index 08ae8935a..ebbb13aaf 100644 --- a/python/src/deltachat/testplugin.py +++ b/python/src/deltachat/testplugin.py @@ -309,7 +309,7 @@ class ACSetup: def wait_one_configured(self, account): """wait until this account has successfully configured.""" if self._account2state[account] == self.CONFIGURING: - while 1: + while True: acc = self._pop_config_success() if acc == account: break @@ -638,7 +638,7 @@ class BotProcess: def _run_stdout_thread(self) -> None: try: - while 1: + while True: line = self.popen.stdout.readline() if not line: break @@ -659,7 +659,7 @@ class BotProcess: for next_pattern in patterns: print("+++FNMATCH:", next_pattern) ignored = [] - while 1: + while True: line = self.stdout_queue.get() if line is None: if ignored: diff --git a/python/src/deltachat/tracker.py b/python/src/deltachat/tracker.py index 24665ea64..2dc2ad41b 100644 --- a/python/src/deltachat/tracker.py +++ b/python/src/deltachat/tracker.py @@ -85,7 +85,7 @@ class ConfigureTracker: self._imap_finished.wait() def wait_progress(self, data1=None): - while 1: + while True: evdata = self._progress.get() if data1 is None or evdata == data1: break