batch 2 - update Python idiom to 3.7 using pyupgrade (#11342)

* batch 2 - update Python idiom to 3.7 using pyupgrade

* Apply suggestions from code review
This commit is contained in:
Alexei Znamensky
2025-12-30 22:50:16 +13:00
committed by GitHub
parent 9e363c9f94
commit 266d9d3fb0
19 changed files with 64 additions and 70 deletions

View File

@@ -17,13 +17,13 @@ def main():
with open(".azure-pipelines/azure-pipelines.yml", "rb") as f:
azp = yaml.safe_load(f)
allowed_targets = set(["azp/generic/1"])
allowed_targets = {"azp/generic/1"}
for stage in azp["stages"]:
if stage["stage"].startswith(("Sanity", "Unit", "Generic", "Summary")):
continue
for job in stage["jobs"]:
for group in job["parameters"]["groups"]:
allowed_targets.add("azp/posix/{0}".format(group))
allowed_targets.add(f"azp/posix/{group}")
paths = glob.glob("tests/integration/targets/*/aliases")
@@ -31,7 +31,7 @@ def main():
for path in paths:
targets = []
skip = False
with open(path, "r") as f:
with open(path) as f:
for line in f:
if "#" in line:
line = line[: line.find("#")]
@@ -56,11 +56,11 @@ def main():
if not targets:
if "targets/setup_" in path:
continue
print("%s: %s" % (path, "found no targets"))
print(f"{path}: found no targets")
has_errors = True
for target in targets:
if target not in allowed_targets:
print("%s: %s" % (path, 'found invalid target "{0}"'.format(target)))
print(f'{path}: found invalid target "{target}"')
has_errors = True
return 1 if has_errors else 0

View File

@@ -70,7 +70,7 @@ class BotmetaCheck:
try:
documentation = []
in_docs = False
with open(filename, "r", encoding="utf-8") as f:
with open(filename, encoding="utf-8") as f:
for line in f:
if line.startswith("DOCUMENTATION ="):
in_docs = True