4 ms·
It's not possible to infer that the result `return x == y` is a bool, because python has rich comparisons (e.g. if x an y are numpy arrays you'll get an array o
by patrec 9y ago
It's not possible to infer that the result `return x == y` is a bool, because python has rich comparisons (e.g. if x an y are numpy arrays you'll get an array of the same shape (after broadcasting) back). So either pytype uses additional information, or it's sometimes just wrong.
- yegle 9y agoTechnically true, since you'll need to check the return type of `__eq__()`. But the following code doesn't trigger any error using `mypy test.py --check-untyped-defs`. def foo(): x = 1 return x == 2 def bar(x: bool): print(x) def baz(x: int): print(x) if __name__ == '__main__': bar(foo()) baz(foo())