def METHOD_NAME(self, path: str, attr: SFTPAttributes) -> int:
    self.session.sftp_client_ready.wait()
    if self.session.sftp_client is None:
        raise MissingClient("self.session.sftp_client is None!")
    if attr.st_mode:
        return self.session.sftp_client.chmod(path, attr.st_mode)
    remotestat = self.stat(path)
    if isinstance(remotestat, int):
        return remotestat
    oldattr = paramiko.SFTPAttributes.from_stat(cast(os.stat_result, remotestat))
    if not attr.st_uid:
        attr.st_uid = oldattr.st_uid
    if not attr.st_gid:
        attr.st_gid = oldattr.st_gid
    if attr.st_uid is None or attr.st_gid is None:
        return paramiko.sftp.SFTP_FAILURE
    return self.session.sftp_client.chown(path, attr.st_uid, attr.st_gid)