From d6715cff2e5a1771b22bb2ce7680347cad501841 Mon Sep 17 00:00:00 2001 From: BonfaceKilz Date: Tue, 29 Jun 2021 13:16:09 +0300 Subject: Replace list with a tuple as an argument when setting success_codes * gn3/commands.py (run_cmd): Replace type of success_codes from List to Tuple * gn3/computations/diff.py (generate_diff): Pass success_codes as a Tuple when calling "run_cmd". --- gn3/commands.py | 3 ++- gn3/computations/diff.py | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'gn3') diff --git a/gn3/commands.py b/gn3/commands.py index 0f526d8..7d42ced 100644 --- a/gn3/commands.py +++ b/gn3/commands.py @@ -6,6 +6,7 @@ from datetime import datetime from typing import Dict from typing import List from typing import Optional +from typing import Tuple from uuid import uuid4 from redis.client import Redis # Used only in type hinting @@ -74,7 +75,7 @@ Returns the name of the specific redis hash for the specific task. return unique_id -def run_cmd(cmd: str, success_codes: List = [0]) -> Dict: +def run_cmd(cmd: str, success_codes: Tuple = (0,)) -> Dict: """Run CMD and return the CMD's status code and output as a dict""" results = subprocess.run(cmd, capture_output=True, shell=True, check=False) diff --git a/gn3/computations/diff.py b/gn3/computations/diff.py index 4bbc6cf..af02f7f 100644 --- a/gn3/computations/diff.py +++ b/gn3/computations/diff.py @@ -6,7 +6,7 @@ from gn3.commands import run_cmd def generate_diff(data: str, edited_data: str) -> Optional[str]: """Generate the diff between 2 files""" - results = run_cmd(f"diff {data} {edited_data}", success_codes=[1, 2]) + results = run_cmd(f"diff {data} {edited_data}", success_codes=(1, 2)) if results.get("code", -1) > 0: return results.get("output") return None -- cgit v1.2.3