In a rural area, a driver can have greater leeway for lateral positioning. In an urban environment, however, it can be difficult to track all potential conflicting movements or threats. Taking a lane position to minimize them where practical can indeed reduce the risk, but not eliminate the risk.
I will digress off-topic for one important exception: a rider can practically eliminate just about all risk from a suddenly opening car door by simply not riding in its swept width. This is feasible on most roadways with on-street parking. In locations where such a lane position might increase exposure to overtaking traffic, it's my understanding that the dooring risk significantly outweighs the overtaking risk, except under unusually high overtaking speeds or volumes. Some riders feel comfortable riding adjacent to parked vehicles, apparently assuming that they can detect occupancy and react in time to an opening door. However, tinted windows, larger or taller vehicles, and ubiquitous headrests make that detection task impractical at cycling speeds, plus a door can go from closed from fully open in half a second, while the rider is still in the perception region of the perception-reaction response.