python: replace "while 1" with "while True"

This makes pyright recognize that the function never returns implicitly.
This commit is contained in:
link2xt
2023-02-18 11:31:07 +00:00
parent 7586bcf45e
commit 48fee4fc92
4 changed files with 14 additions and 14 deletions

View File

@@ -207,14 +207,14 @@ class IdleManager:
return res return res
def wait_for_new_message(self, timeout=None) -> bytes: def wait_for_new_message(self, timeout=None) -> bytes:
while 1: while True:
for item in self.check(timeout=timeout): for item in self.check(timeout=timeout):
if b"EXISTS" in item or b"RECENT" in item: if b"EXISTS" in item or b"RECENT" in item:
return item return item
def wait_for_seen(self, timeout=None) -> int: def wait_for_seen(self, timeout=None) -> int:
"""Return first message with SEEN flag from a running idle-stream.""" """Return first message with SEEN flag from a running idle-stream."""
while 1: while True:
for item in self.check(timeout=timeout): for item in self.check(timeout=timeout):
if FETCH in item: if FETCH in item:
self.log(str(item)) self.log(str(item))

View File

@@ -108,7 +108,7 @@ class FFIEventTracker:
return ev return ev
def iter_events(self, timeout=None, check_error=True): def iter_events(self, timeout=None, check_error=True):
while 1: while True:
yield self.get(timeout=timeout, check_error=check_error) yield self.get(timeout=timeout, check_error=check_error)
def get_matching(self, event_name_regex, check_error=True, timeout=None): 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: def get_info_contains(self, regex: str) -> FFIEvent:
rex = re.compile(regex) rex = re.compile(regex)
while 1: while True:
ev = self.get_matching("DC_EVENT_INFO") ev = self.get_matching("DC_EVENT_INFO")
if rex.search(ev.data2): if rex.search(ev.data2):
return ev return ev
def get_info_regex_groups(self, regex, check_error=True): def get_info_regex_groups(self, regex, check_error=True):
rex = re.compile(regex) rex = re.compile(regex)
while 1: while True:
ev = self.get_matching("DC_EVENT_INFO", check_error=check_error) ev = self.get_matching("DC_EVENT_INFO", check_error=check_error)
m = rex.match(ev.data2) m = rex.match(ev.data2)
if m is not None: if m is not None:
@@ -137,7 +137,7 @@ class FFIEventTracker:
This only works reliably if the connectivity doesn't change This only works reliably if the connectivity doesn't change
again too quickly, otherwise we might miss it. again too quickly, otherwise we might miss it.
""" """
while 1: while True:
if self.account.get_connectivity() == connectivity: if self.account.get_connectivity() == connectivity:
return return
self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")
@@ -146,7 +146,7 @@ class FFIEventTracker:
"""Wait until the connectivity changes to `expected_next`. """Wait until the connectivity changes to `expected_next`.
Fails the test if it changes to something else. Fails the test if it changes to something else.
""" """
while 1: while True:
current = self.account.get_connectivity() current = self.account.get_connectivity()
if current == expected_next: if current == expected_next:
return return
@@ -156,7 +156,7 @@ class FFIEventTracker:
self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")
def wait_for_all_work_done(self): def wait_for_all_work_done(self):
while 1: while True:
if self.account.all_work_done(): if self.account.all_work_done():
return return
self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED") self.get_matching("DC_EVENT_CONNECTIVITY_CHANGED")
@@ -164,7 +164,7 @@ class FFIEventTracker:
def ensure_event_not_queued(self, event_name_regex): def ensure_event_not_queued(self, event_name_regex):
__tracebackhide__ = True __tracebackhide__ = True
rex = re.compile(f"(?:{event_name_regex}).*") rex = re.compile(f"(?:{event_name_regex}).*")
while 1: while True:
try: try:
ev = self._event_queue.get(False) ev = self._event_queue.get(False)
except Empty: except Empty:
@@ -173,7 +173,7 @@ class FFIEventTracker:
assert not rex.match(ev.name), f"event found {ev}" assert not rex.match(ev.name), f"event found {ev}"
def wait_securejoin_inviter_progress(self, target): def wait_securejoin_inviter_progress(self, target):
while 1: while True:
event = self.get_matching("DC_EVENT_SECUREJOIN_INVITER_PROGRESS") event = self.get_matching("DC_EVENT_SECUREJOIN_INVITER_PROGRESS")
if event.data2 >= target: if event.data2 >= target:
print(f"** SECUREJOINT-INVITER PROGRESS {target}", self.account) print(f"** SECUREJOINT-INVITER PROGRESS {target}", self.account)

View File

@@ -309,7 +309,7 @@ class ACSetup:
def wait_one_configured(self, account): def wait_one_configured(self, account):
"""wait until this account has successfully configured.""" """wait until this account has successfully configured."""
if self._account2state[account] == self.CONFIGURING: if self._account2state[account] == self.CONFIGURING:
while 1: while True:
acc = self._pop_config_success() acc = self._pop_config_success()
if acc == account: if acc == account:
break break
@@ -638,7 +638,7 @@ class BotProcess:
def _run_stdout_thread(self) -> None: def _run_stdout_thread(self) -> None:
try: try:
while 1: while True:
line = self.popen.stdout.readline() line = self.popen.stdout.readline()
if not line: if not line:
break break
@@ -659,7 +659,7 @@ class BotProcess:
for next_pattern in patterns: for next_pattern in patterns:
print("+++FNMATCH:", next_pattern) print("+++FNMATCH:", next_pattern)
ignored = [] ignored = []
while 1: while True:
line = self.stdout_queue.get() line = self.stdout_queue.get()
if line is None: if line is None:
if ignored: if ignored:

View File

@@ -85,7 +85,7 @@ class ConfigureTracker:
self._imap_finished.wait() self._imap_finished.wait()
def wait_progress(self, data1=None): def wait_progress(self, data1=None):
while 1: while True:
evdata = self._progress.get() evdata = self._progress.get()
if data1 is None or evdata == data1: if data1 is None or evdata == data1:
break break