From d91472c40650f6302080c2e5c8183b0939077ecf Mon Sep 17 00:00:00 2001 From: Kyle King Date: Wed, 7 Feb 2024 04:42:39 -0500 Subject: [PATCH] refactor: remove unnecessary locals --- mdformat_tables/plugin.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/mdformat_tables/plugin.py b/mdformat_tables/plugin.py index deef933..6b86834 100644 --- a/mdformat_tables/plugin.py +++ b/mdformat_tables/plugin.py @@ -32,18 +32,19 @@ def _to_string( def join_row(items: Union[Iterable[str], Sequence[str]]) -> str: return "| " + " | ".join(items) + " |" - def format_delimeter_row(index: int, align: str) -> str: - left = ":" if align in ("<", "^") else "-" - middle = "-" * max(0, widths[index] - 2) - right = ":" if align in (">", "^") else "-" - delim = left + middle + right + def format_delimiter_cell(index: int, align: str) -> str: + delim = ( + (":" if align in ("<", "^") else "-") + + ("-" * max(0, widths[index] - 2)) + + (":" if align in (">", "^") else "-") + ) return ":-:" if delim == "::" else delim header = join_row( f"{{:{al or '<'}{widths[i]}}}".format(text) for i, (text, al) in enumerate(zip(rows[0], align[0])) ) - delimiter = join_row((format_delimeter_row(i, al) for i, al in enumerate(align[0]))) + delimiter = join_row((format_delimiter_cell(i, al) for i, al in enumerate(align[0]))) rows = [ join_row( f"{{:{al or '<'}{widths[i]}}}".format(text)