Start here
The safe first move
For straightforward paths, replace the string with the mapped attribute, like joinedload(User.addresses).
Stop before automation when: Dotted paths like joinedload("orders.items"). contains_eager and duplicate-join interactions.
Target shape
query = session.query(User).options(joinedload(User.addresses))
query = query.options(selectinload(User.orders))