Use single isinstance call for multiple types

This commit is contained in:
Hugo van Kemenade 2023-01-07 20:25:50 +02:00
parent f30eb38e31
commit b2b8c833aa
2 changed files with 3 additions and 5 deletions

View File

@ -328,9 +328,7 @@ def pdf_repr(x):
return b"null"
elif isinstance(x, (PdfName, PdfDict, PdfArray, PdfBinary)):
return bytes(x)
elif isinstance(x, int):
return str(x).encode("us-ascii")
elif isinstance(x, float):
elif isinstance(x, (int, float)):
return str(x).encode("us-ascii")
elif isinstance(x, time.struct_time):
return b"(D:" + time.strftime("%Y%m%d%H%M%SZ", x).encode("us-ascii") + b")"

View File

@ -39,7 +39,7 @@ def cmd_rmdir(path):
def cmd_nmake(makefile=None, target="", params=None):
if params is None:
params = ""
elif isinstance(params, list) or isinstance(params, tuple):
elif isinstance(params, (list, tuple)):
params = " ".join(params)
else:
params = str(params)
@ -58,7 +58,7 @@ def cmd_nmake(makefile=None, target="", params=None):
def cmd_cmake(params=None, file="."):
if params is None:
params = ""
elif isinstance(params, list) or isinstance(params, tuple):
elif isinstance(params, (list, tuple)):
params = " ".join(params)
else:
params = str(params)