mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-08 06:12:51 +00:00
Clean up other Python files (#11379)
* Address issues found by ruff check. * Make mypy happy; remove some Python 2 compat code. * Also declare port1.
This commit is contained in:
@@ -43,20 +43,20 @@ def main():
|
||||
jobs[label] = max(attempt, jobs.get(label, 0))
|
||||
|
||||
for label, attempt in jobs.items():
|
||||
name = "Coverage {attempt} {label}".format(label=label, attempt=attempt)
|
||||
name = f"Coverage {attempt} {label}"
|
||||
source = os.path.join(source_directory, name)
|
||||
source_files = os.listdir(source)
|
||||
|
||||
for source_file in source_files:
|
||||
source_path = os.path.join(source, source_file)
|
||||
destination_path = os.path.join(destination_directory, source_file + "." + label)
|
||||
print('"%s" -> "%s"' % (source_path, destination_path))
|
||||
print(f'"{source_path}" -> "{destination_path}"')
|
||||
shutil.copyfile(source_path, destination_path)
|
||||
count += 1
|
||||
|
||||
print("Coverage file count: %d" % count)
|
||||
print("##vso[task.setVariable variable=coverageFileCount]%d" % count)
|
||||
print("##vso[task.setVariable variable=outputPath]%s" % output_path)
|
||||
print(f"Coverage file count: {count}")
|
||||
print(f"##vso[task.setVariable variable=coverageFileCount]{count}")
|
||||
print(f"##vso[task.setVariable variable=outputPath]{output_path}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -15,7 +15,6 @@ import pathlib
|
||||
import shutil
|
||||
import subprocess
|
||||
import tempfile
|
||||
import typing as t
|
||||
import urllib.request
|
||||
|
||||
|
||||
@@ -23,7 +22,7 @@ import urllib.request
|
||||
class CoverageFile:
|
||||
name: str
|
||||
path: pathlib.Path
|
||||
flags: t.List[str]
|
||||
flags: list[str]
|
||||
|
||||
|
||||
@dataclasses.dataclass(frozen=True)
|
||||
@@ -46,7 +45,7 @@ def parse_args() -> Args:
|
||||
return Args(**kwargs)
|
||||
|
||||
|
||||
def process_files(directory: pathlib.Path) -> t.Tuple[CoverageFile, ...]:
|
||||
def process_files(directory: pathlib.Path) -> tuple[CoverageFile, ...]:
|
||||
processed = []
|
||||
for file in directory.joinpath("reports").glob("coverage*.xml"):
|
||||
name = file.stem.replace("coverage=", "")
|
||||
@@ -62,7 +61,7 @@ def process_files(directory: pathlib.Path) -> t.Tuple[CoverageFile, ...]:
|
||||
return tuple(processed)
|
||||
|
||||
|
||||
def upload_files(codecov_bin: pathlib.Path, files: t.Tuple[CoverageFile, ...], dry_run: bool = False) -> None:
|
||||
def upload_files(codecov_bin: pathlib.Path, files: tuple[CoverageFile, ...], dry_run: bool = False) -> None:
|
||||
for file in files:
|
||||
cmd = [
|
||||
str(codecov_bin),
|
||||
|
||||
@@ -20,7 +20,7 @@ def main():
|
||||
|
||||
for line in sys.stdin:
|
||||
seconds = time.time() - start
|
||||
sys.stdout.write("%02d:%02d %s" % (seconds // 60, seconds % 60, line))
|
||||
sys.stdout.write(f"{seconds // 60:02}:{seconds % 60:02} {line}")
|
||||
sys.stdout.flush()
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user