It looks to me like redis.size should always be == keys.size, because Redis returns EmptyBulkReply for missing keys, which is getting mapped, in the code you linked, to None. So you can probably just throw an exception on this line if it ever happens, because it's not supposed to IIUC.