code: def _remote_expand_user(self, path, sudoable=True):
          
          LOG.debug('_remote_expand_user(%r, sudoable=%r)', path, sudoable)
          if not path.startswith('~'):
              # /home/foo -> /home/foo
              return path
          if sudoable or not self._play_context.become:
              if path == '~':
                  # ~ -> /home/dmw
                  return self._connection.homedir
              if path.startswith('~/'):
                  # ~/.ansible -> /home/dmw/.ansible
                  return os.path.join(self._connection.homedir, path[2:])
          # ~root/.ansible -> /root/.ansible
          return self._connection.get_chain(use_login=(not sudoable)).call(
              os.path.expanduser,
              mitogen.utils.cast(path),
          )
docs: Replace the base implementation's attempt to emulate
          os.path.expanduser() with an actual call to os.path.expanduser().
  
          :param bool sudoable:
              If :data:`True`, indicate unqualified tilde ("~" with no username)
              should be evaluated in the context of the login account, not any
              become_user.