Skip to content

Commit

Permalink
Fix Current Pylint Errors
Browse files Browse the repository at this point in the history
= 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
  • Loading branch information
sdimitro committed Apr 29, 2021
1 parent d0cb398 commit 7a9067b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions sdb/commands/zfs/histograms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 **')
Expand Down
6 changes: 6 additions & 0 deletions sdb/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 7a9067b

Please sign in to comment.