ruff: Fix PLW2901 for loop variable overwritten by assignment target.

Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2023-10-30 10:53:40 -07:00
parent 18805ac181
commit 12e63f493f
2 changed files with 6 additions and 7 deletions

View file

@ -215,11 +215,10 @@ for status in statuses[::-1][: opts.limit_tweets]:
if opts.search_terms: if opts.search_terms:
search_term_used = None search_term_used = None
for term in opts.search_terms.split(","): for raw_term in opts.search_terms.split(","):
# Remove quotes from phrase: # Remove quotes from phrase:
# "Zulip API" -> Zulip API # "Zulip API" -> Zulip API
if term.startswith('"') and term.endswith('"'): term = raw_term[1:-1] if term.startswith('"') and term.endswith('"') else raw_term
term = term[1:-1]
if any(term.lower() in text for text in text_to_check): if any(term.lower() in text for text in text_to_check):
search_term_used = term search_term_used = term
break break

View file

@ -98,8 +98,8 @@ def unwrap_lines(body: str) -> str:
lines = body.split("\n") lines = body.split("\n")
result = "" result = ""
previous_line = lines[0] previous_line = lines[0]
for line in lines[1:]: for raw_line in lines[1:]:
line = line.rstrip() line = raw_line.rstrip()
if re.match(r"^\W", line, flags=re.UNICODE) and re.match( if re.match(r"^\W", line, flags=re.UNICODE) and re.match(
r"^\W", previous_line, flags=re.UNICODE r"^\W", previous_line, flags=re.UNICODE
): ):
@ -1096,8 +1096,8 @@ def parse_zephyr_subs(verbose: bool = False) -> Set[Tuple[str, str, str]]:
logger.error("Couldn't find ~/.zephyr.subs!") logger.error("Couldn't find ~/.zephyr.subs!")
return zephyr_subscriptions return zephyr_subscriptions
for line in open(subs_file).readlines(): for raw_line in open(subs_file).readlines():
line = line.strip() line = raw_line.strip()
if len(line) == 0: if len(line) == 0:
continue continue
try: try: