type
operand placement PTC-W0024type
should be on the left side of the comparision operator1112 if not raw_arg.endswith("\n"):
1113 raw_arg += "\n"
1114 arg = execer.exec(raw_arg, mode=mode, glbs=glbs, locs=locs, filename=filename)
1115 elif kind is type:1116 arg = type(execer.eval(raw_arg, glbs=glbs, locs=locs, filename=filename))
1117 else:
1118 msg = "kind={0!r} and mode={1!r} was not recognized for macro " "argument {2!r}"
The type()
call shall be placed on the left side of the comparison when checking the type of one object against another type.
This affects readability.
x = 42
if int is type(x):
print('This is an integer')
x = 42
if type(x) is int:
print('This is an integer')
Or even better, use isinstance
:
x = 42
if isinstance(x, int):
print('This is an integer')