def _should_update(self, dist: Distribution, can: Candidate) -> bool:
        """Check if the candidate should be updated"""
        backend = self.environment.project.backend
        if self.reinstall or can.req.editable:  # Always update if incoming is editable
            return True
        if is_editable(dist):  # only update editable if no_editable is True
            return bool(self.no_editable)
        if not can.req.is_named:
            dreq = Requirement.from_dist(dist)
            if not isinstance(dreq, FileRequirement):
                return True
            url = dreq.get_full_url()
            if dreq.is_local_dir:
                # We don't know whether a local dir has been changed, always update
                return True
            assert can.link is not None
            if url != backend.expand_line(can.link.url_without_fragment):
                return True
            direct_json = json.loads(content) if (content := dist.read_text("direct_url.json")) else None
            if not direct_json or "archive_info" not in direct_json:
                # We are not able to check, don't update
                return False
            dist_hash = direct_json["archive_info"]["hash"].replace("=", ":")
            return not any(dist_hash == file_hash["hash"] for file_hash in can.hashes)
        specifier = can.req.as_pinned_version(can.version).specifier
        return not specifier.contains(dist.version, prereleases=True)
Check if the candidate should be updated
src/pdm/installers/base.py