def comparable_version(version: str) -> Version:
    """Normalize a version to make it valid in a specifier."""
    parsed = parse_version(version or "0.0.0")
    if parsed.local is not None:
        # strip the local part
        parsed._version = parsed._version._replace(local=None)

        # To make comparable_version("1.2.3+local1") == Version("1.2.3")
        parsed._key = _cmpkey(
            parsed._version.epoch,
            parsed._version.release,
            parsed._version.pre,
            parsed._version.post,
            parsed._version.dev,
            parsed._version.local,
        )

    return parsed
Normalize a version to make it valid in a specifier.
src/pdm/utils.py