From 5d67f8ca2a11d30626f03e0df0d9bef432b3e9c5 Mon Sep 17 00:00:00 2001 From: Satellite QE <115476073+Satellite-QE@users.noreply.github.com> Date: Thu, 31 Oct 2024 10:28:59 -0400 Subject: [PATCH] [6.13.z] [pre-commit.ci] pre-commit autoupdate (#16826) --- .pre-commit-config.yaml | 4 ++-- robottelo/utils/io/__init__.py | 9 ++++----- tests/robottelo/test_func_locker.py | 7 +++---- 3 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 90c79eefab7..3d528a007ff 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -12,7 +12,7 @@ repos: - id: check-yaml - id: debug-statements - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.6.9 + rev: v0.7.1 hooks: - id: ruff args: [--fix, --exit-non-zero-on-fix] @@ -28,6 +28,6 @@ repos: types: [text] require_serial: true - repo: https://github.com/gitleaks/gitleaks - rev: v8.20.1 + rev: v8.21.2 hooks: - id: gitleaks diff --git a/robottelo/utils/io/__init__.py b/robottelo/utils/io/__init__.py index ac23b5e83b5..bb7195f8b6e 100644 --- a/robottelo/utils/io/__init__.py +++ b/robottelo/utils/io/__init__.py @@ -18,11 +18,10 @@ def get_local_file_data(path): checksum = hashlib.sha256(file_content).hexdigest() try: - tarobj = tarfile.open(path, mode='r') - host_counts = get_host_counts(tarobj) - tarobj.close() - extractable = True - json_files_parsable = True + with tarfile.open(path, mode='r') as tarobj: + host_counts = get_host_counts(tarobj) + extractable = True + json_files_parsable = True except (tarfile.TarError, json.JSONDecodeError): host_counts = {} extractable = False diff --git a/tests/robottelo/test_func_locker.py b/tests/robottelo/test_func_locker.py index de2ef29aa33..4a4fbbddd0b 100644 --- a/tests/robottelo/test_func_locker.py +++ b/tests/robottelo/test_func_locker.py @@ -28,10 +28,9 @@ class TmpCountFile: def __init__(self): tmp_root_path = Path(func_locker.get_temp_dir()).joinpath(func_locker.TEMP_ROOT_DIR) tmp_root_path.mkdir(parents=True, exist_ok=True) - self.file = tempfile.NamedTemporaryFile(delete=False, suffix='.counter', dir=tmp_root_path) - self.file_name = self.file.name - self.file.write(b'0') - self.file.close() + with tempfile.NamedTemporaryFile(delete=False, suffix='.counter', dir=tmp_root_path) as cf: + cf.write(b'0') + self.file_name = cf.name def read(self): with open(self.file_name) as cf: