From 7a9067bc91fabc5e767db2674c7b6bd3a1d3458e Mon Sep 17 00:00:00 2001 From: Serapheim Dimitropoulos Date: Mon, 26 Apr 2021 08:54:59 -0700 Subject: [PATCH] Fix Current Pylint Errors = Before The Patch We'd get the following error from our `pylint` action: ``` ************* Module sdb.pipeline sdb/pipeline.py:132:8: R1732: Consider using 'with' for resource-allocating operations (consider-using-with) ************* Module sdb.commands.zfs.histograms sdb/commands/zfs/histograms.py:136:8: R1731: Consider using 'max_count = max(max_count, HISTOGRAM_WIDTH_MAX)' instead of unnecessary if block (consider-using-max-builtin) ``` = After the Patch Pylint runs fine with no errors --- sdb/commands/zfs/histograms.py | 3 +-- sdb/pipeline.py | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/sdb/commands/zfs/histograms.py b/sdb/commands/zfs/histograms.py index 6f9eb48e..04bc4809 100644 --- a/sdb/commands/zfs/histograms.py +++ b/sdb/commands/zfs/histograms.py @@ -133,8 +133,7 @@ def print_histogram(hist: drgn.Object, max_count = count HISTOGRAM_WIDTH_MAX = 40 - if max_count < HISTOGRAM_WIDTH_MAX: - max_count = HISTOGRAM_WIDTH_MAX + max_count = max(max_count, HISTOGRAM_WIDTH_MAX) if min_bucket > max_bucket: print(f'{" " * indent}** No histogram data available **') diff --git a/sdb/pipeline.py b/sdb/pipeline.py index 35b39fe9..f5a2dac3 100644 --- a/sdb/pipeline.py +++ b/sdb/pipeline.py @@ -129,6 +129,12 @@ def invoke(myprog: drgn.Program, first_input: Iterable[drgn.Object], # at the end. # if shell_cmd is not None: + # + # This is a false-positive from pylint as we need + # to explicitly wait for shell_proc to be done and + # re-arrange our std_out. + # + # pylint: disable=consider-using-with shell_proc = subprocess.Popen(shell_cmd, shell=True, stdin=subprocess.PIPE,