Closed
Description
The following code generates an error on latest master but no on latest release (with --enable-error-codes=truthy-bool
):
def f(obj: object) -> None:
print("{}".format(
getattr(type(obj), "__foo__", "") or "unknown" # E: "builtins.getattr" returns "object" which does not implement __bool__ or __len__ so it could always be true in boolean context [truthy-bool]
))
f("")
It's clearly a false positive, if your run the code you see that it prints unknown
.