11"""Pretty-print tabular data."""
22
33from collections import namedtuple
4- from collections .abc import Iterable , Sized
4+ from collections .abc import Callable , Iterable , Sized
55import dataclasses
66from dataclasses import dataclass
77from decimal import Decimal
1313import math
1414import re
1515import textwrap
16- from typing import Callable , Union
1716import warnings
1817
1918try :
@@ -1045,7 +1044,7 @@ def _padleft(width, s):
10451044 True
10461045
10471046 """
1048- fmt = "{ 0:>%ds}" % width
1047+ fmt = f"{{ 0:>{ width } s}}"
10491048 return fmt .format (s )
10501049
10511050
@@ -1056,7 +1055,7 @@ def _padright(width, s):
10561055 True
10571056
10581057 """
1059- fmt = "{ 0:<%ds}" % width
1058+ fmt = f"{{ 0:<{ width } s}}"
10601059 return fmt .format (s )
10611060
10621061
@@ -1067,7 +1066,7 @@ def _padboth(width, s):
10671066 True
10681067
10691068 """
1070- fmt = "{ 0:^%ds}" % width
1069+ fmt = f"{{ 0:^{ width } s}}"
10711070 return fmt .format (s )
10721071
10731072
@@ -2528,7 +2527,7 @@ def _build_row(
25282527 padded_cells : list [list ],
25292528 colwidths : list [int ],
25302529 colaligns : list [str ],
2531- rowfmt : Union [ DataRow , Callable ] ,
2530+ rowfmt : DataRow | Callable ,
25322531) -> str :
25332532 "Return a string which represents a row of data cells."
25342533 if not rowfmt :
@@ -2804,7 +2803,7 @@ def _wrap_chunks(self, chunks):
28042803 """
28052804 lines = []
28062805 if self .width <= 0 :
2807- raise ValueError ("invalid width %r (must be > 0)" % self . width )
2806+ raise ValueError (f "invalid width { self . width !r } (must be > 0)" )
28082807 if self .max_lines is not None :
28092808 if self .max_lines > 1 :
28102809 indent = self .subsequent_indent
0 commit comments