_structures.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. """Vendoered from
  2. https://github.com/pypa/packaging/blob/main/packaging/_structures.py
  3. """
  4. # Copyright (c) Donald Stufft and individual contributors.
  5. # All rights reserved.
  6. # Redistribution and use in source and binary forms, with or without
  7. # modification, are permitted provided that the following conditions are met:
  8. # 1. Redistributions of source code must retain the above copyright notice,
  9. # this list of conditions and the following disclaimer.
  10. # 2. Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in the
  12. # documentation and/or other materials provided with the distribution.
  13. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
  14. # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  15. # WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  16. # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  17. # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  18. # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  19. # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  20. # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  22. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  23. class InfinityType:
  24. def __repr__(self) -> str:
  25. return "Infinity"
  26. def __hash__(self) -> int:
  27. return hash(repr(self))
  28. def __lt__(self, other: object) -> bool:
  29. return False
  30. def __le__(self, other: object) -> bool:
  31. return False
  32. def __eq__(self, other: object) -> bool:
  33. return isinstance(other, self.__class__)
  34. def __ne__(self, other: object) -> bool:
  35. return not isinstance(other, self.__class__)
  36. def __gt__(self, other: object) -> bool:
  37. return True
  38. def __ge__(self, other: object) -> bool:
  39. return True
  40. def __neg__(self: object) -> "NegativeInfinityType":
  41. return NegativeInfinity
  42. Infinity = InfinityType()
  43. class NegativeInfinityType:
  44. def __repr__(self) -> str:
  45. return "-Infinity"
  46. def __hash__(self) -> int:
  47. return hash(repr(self))
  48. def __lt__(self, other: object) -> bool:
  49. return True
  50. def __le__(self, other: object) -> bool:
  51. return True
  52. def __eq__(self, other: object) -> bool:
  53. return isinstance(other, self.__class__)
  54. def __ne__(self, other: object) -> bool:
  55. return not isinstance(other, self.__class__)
  56. def __gt__(self, other: object) -> bool:
  57. return False
  58. def __ge__(self, other: object) -> bool:
  59. return False
  60. def __neg__(self: object) -> InfinityType:
  61. return Infinity
  62. NegativeInfinity = NegativeInfinityType()