Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/icalendar/compatibility.py: 46%

Shortcuts on this page

r m x   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

24 statements  

1"""This module contains compatibility code for older Python versions.""" 

2 

3import sys 

4from typing import TYPE_CHECKING 

5 

6try: 

7 from typing import Self 

8except ImportError: 

9 try: 

10 from typing_extensions import Self 

11 except ImportError: 

12 Self = "Self" 

13 

14try: 

15 import zoneinfo 

16except ImportError: 

17 import backports.zoneinfo as zoneinfo 

18 

19ZoneInfo = zoneinfo.ZoneInfo 

20 

21if TYPE_CHECKING: 

22 if sys.version_info >= (3, 10): 

23 from typing import TypeGuard 

24 else: 

25 from typing_extensions import TypeGuard 

26 

27 if sys.version_info >= (3, 13): 

28 from typing import TypeIs 

29 else: 

30 from typing_extensions import TypeIs 

31else: 

32 # we cannot use a TypeGuard = "TypeGuard" hack since it's used with a parameter 

33 TypeGuard = TypeIs = None 

34 

35__all__ = [ 

36 "Self", 

37 "TypeIs", 

38 "TypeGuard", 

39 "ZoneInfo", 

40 "zoneinfo", 

41]