Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.8/site-packages/validators/_extremes.py: 80%

10 statements  

« prev     ^ index     » next       coverage.py v7.2.7, created at 2023-06-07 06:08 +0000

1"""Extremes.""" 

2# -*- coding: utf-8 -*- 

3 

4# standard 

5from functools import total_ordering 

6from typing import Any 

7 

8 

9@total_ordering 

10class AbsMax: 

11 """An object that is greater than any other object (except itself). 

12 

13 Inspired by https://pypi.python.org/pypi/Extremes. 

14 

15 Examples: 

16 >>> from sys import maxint 

17 >>> AbsMax > AbsMin 

18 # Output: True 

19 >>> AbsMax > maxint 

20 # Output: True 

21 >>> AbsMax > 99999999999999999 

22 # Output: True 

23 

24 > *New in version 0.2.0*. 

25 """ 

26 

27 def __ge__(self, other: Any): 

28 """GreaterThanOrEqual.""" 

29 return other is not AbsMax 

30 

31 

32@total_ordering 

33class AbsMin: 

34 """An object that is less than any other object (except itself). 

35 

36 Inspired by https://pypi.python.org/pypi/Extremes. 

37 

38 Examples: 

39 >>> from sys import maxint 

40 >>> AbsMin < -maxint 

41 # Output: True 

42 >>> AbsMin < None 

43 # Output: True 

44 >>> AbsMin < '' 

45 # Output: True 

46 

47 > *New in version 0.2.0*. 

48 """ 

49 

50 def __le__(self, other: Any): 

51 """LessThanOrEqual.""" 

52 return other is not AbsMin