[PR #11343/e8f2b135 backport][stable-12] batch 3 - update Python idiom to 3.7 using pyupgrade (#11352)

batch 3 - update Python idiom to 3.7 using pyupgrade (#11343)

* batch 3 - update Python idiom to 3.7 using pyupgrade

* add changelog frag

* bring back sanity

* adjust test

* Apply suggestions from code review

(cherry picked from commit e8f2b135ba)

Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
patchback[bot]
2025-12-30 22:43:24 +01:00
committed by GitHub
parent 2d07481e64
commit f49c5f79a7
26 changed files with 74 additions and 51 deletions

View File

@@ -204,7 +204,7 @@ def main():
# TODO double check if this hack below is still needed.
# Check file for blank lines in effort to avoid "need more than 1 value to unpack" error.
try:
with open(path, "r") as f:
with open(path) as f:
lines = f.readlines()
# If the file gets edited, it returns true, so only edit the file if it has blank lines
@@ -222,7 +222,7 @@ def main():
with open(path, "w") as f:
f.writelines(line for line in lines if line.strip())
except IOError:
except OSError:
# No preexisting file to remove blank lines from
pass