Pretty much what @carljm wrote in a comment here, and what is now described in this TODO comment:
https://github.com/astral-sh/ruff/blob/13a1483f1e51087d7c95922a6b3d2914ac2b68c3/crates/red_knot_python_semantic/src/types.rs#L80-L93
I'm opening this as a ticket as there seems to be an open discussion point regarding the desired behavior:
Possibly the behavior here should differ depending on whether we are importing from a stub or a regular Python module? But an argument could be made that even in a regular Python module, if it declares x: int at module level, we should just trust that and not require that we can see the binding of it.