Skip to content

Commit

Permalink
default all prettytable's to fit within max terminal width
Browse files Browse the repository at this point in the history
  • Loading branch information
0xalpharush committed Jul 18, 2024
1 parent 72cb692 commit 5623018
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions slither/utils/command_line.py
Original file line number Diff line number Diff line change
Expand Up @@ -272,9 +272,7 @@ def output_detectors(detector_classes: List[Type[AbstractDetector]]) -> None:
impact = detector.IMPACT
confidence = classification_txt[detector.CONFIDENCE]
detectors_list.append((argument, help_info, impact, confidence))
table = MyPrettyTable(
["Num", "Check", "What it Detects", "Impact", "Confidence"], max_width="max"
)
table = MyPrettyTable(["Num", "Check", "What it Detects", "Impact", "Confidence"])

# Sort by impact, confidence, and name
detectors_list = sorted(
Expand Down Expand Up @@ -356,7 +354,7 @@ def output_printers(printer_classes: List[Type[AbstractPrinter]]) -> None:
argument = printer.ARGUMENT
help_info = printer.HELP
printers_list.append((argument, help_info))
table = MyPrettyTable(["Num", "Printer", "What it Does"], max_width="max")
table = MyPrettyTable(["Num", "Printer", "What it Does"])

# Sort by impact, confidence, and name
printers_list = sorted(printers_list, key=lambda element: (element[0]))
Expand Down
3 changes: 1 addition & 2 deletions slither/utils/myprettytable.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def __init__(
self,
field_names: List[str],
pretty_align: bool = True,
max_width: Union[int, Literal["max"], None] = None,
max_width: Union[int, None] = "max", # Default value is "max"
):
self._field_names = field_names
self._rows: List = []
Expand All @@ -25,7 +25,6 @@ def __init__(
else:
self._options["set_alignment"] = []

self.max_width = None
if max_width == "max":
# We use (0,0) as a fallback to detect if we are not attached to a terminal
# In this case, we fall back to the default behavior (i.e. printing as much as possible)
Expand Down

0 comments on commit 5623018

Please sign in to comment.