codekingpro/portable-devtools
115k
1# This file is dual licensed under the terms of the Apache License, Version2# 2.0, and the BSD License. See the LICENSE file in the root of this repository3# for complete details.4 5"""Backward-compatibility shim for unpickling Version objects serialized before6packaging 26.1.7 8Old pickles reference ``packaging._structures.InfinityType`` and9``packaging._structures.NegativeInfinityType``. This module provides minimal10stand-in classes so that ``pickle.loads()`` can resolve those references.11The deserialized objects are not used for comparisons — ``Version.__setstate__``12discards the stale ``_key`` cache and recomputes it from the core version fields.13"""14 15from __future__ import annotations16 17 18class InfinityType:19 """Stand-in for the removed ``InfinityType`` used in old comparison keys."""20 21 def __repr__(self) -> str:22 return "Infinity"23 24 25class NegativeInfinityType:26 """Stand-in for the removed ``NegativeInfinityType`` used in old comparison keys."""27 28 def __repr__(self) -> str:29 return "-Infinity"30 31 32Infinity = InfinityType()33NegativeInfinity = NegativeInfinityType()34 