tools: change direct type check to isinstance

Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1072>
This commit is contained in:
Peter Hutterer 2024-10-29 13:26:57 +10:00
parent 5e235a6546
commit 15af1c0017

View file

@ -66,10 +66,10 @@ class TableFormatter(object):
s = "|" s = "|"
for w, arg in zip(self.colwidths, args): for w, arg in zip(self.colwidths, args):
w -= 1 # width includes | separator w -= 1 # width includes | separator
if type(arg) == str: if isinstance(arg, str):
# We want space margins for strings # We want space margins for strings
s += " {:{width}s} |".format(arg, width=w - 2) s += " {:{width}s} |".format(arg, width=w - 2)
elif type(arg) == bool: elif isinstance(arg, bool):
s += "{:^{width}s}|".format("x" if arg else " ", width=w) s += "{:^{width}s}|".format("x" if arg else " ", width=w)
else: else:
s += "{:^{width}d}|".format(arg, width=w) s += "{:^{width}d}|".format(arg, width=w)