ty and zuban also don't give an error. pyright and pyrefly do.
def _(flag: bool):
if flag:
x = True
...
if flag:
read(x)
But it's easy to turn the rule on if you want it: [tool.ty.rules]
possibly-unresolved-reference = "error"