> Given space they might stop, which is pretty discourteous by the person opening the door
Precisely the opposite is true: thoughtfully opening one's door slowly as a backup mechanism in an effort to prevent someone else's injury is very courteous. As a cyclist myself, I'd far prefer to be inconvenienced by an unscheduled stop than I would crash into a car door.
> with insufficient time they might well swerve into a traffic to avoid the collision, which could be far worse.
The alternative in your scenario is the driver impatiently swinging their door open. In this case the cyclist might well serve into traffic, too. Your argument makes no sense to me.
The obligation is on the party obstructing the traffic flow to not be a dick about it (which includes broadcasting their intentions to some extent) and the secondary obligation is on the moving traffic to not do ludicrous speed so that the former party can accurately predict whether or not they can make their move without being a dick about it.
All of this is easier in Dutch cities with bike lanes and because we cycle much slower than the typical "rider" in San Francisco or London I've seen. Mostly because people commute on old slow bicycles in normal clothes instead of light weight geared bikes and full on sports outfits with helmets.