I'd stick brackets around that to remove the possibility of precedence confusion:
```
if not (x.shape == y.shape == ...)
```