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

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

20 statements  

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

2 

3All compatibility checks and imports should go here. 

4This way, we can centralize the handling of different Python versions. 

5 

6Do NOT import this module directly if you use icalendar. 

7Members will be added and removed without deprecation warnings. 

8""" 

9 

10from typing import TYPE_CHECKING 

11 

12try: 

13 from typing import Self 

14except ImportError: 

15 try: 

16 from typing_extensions import Self 

17 except ImportError: 

18 Self = "Self" 

19 

20if TYPE_CHECKING: 

21 import sys 

22 from typing import TypeGuard 

23 

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

25 from typing import TypeIs 

26 else: 

27 from typing_extensions import TypeIs 

28 if sys.version_info >= (3, 11): 

29 from typing import Self 

30 else: 

31 from typing_extensions import Self 

32else: 

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

34 TypeGuard = TypeIs = Self = None 

35 

36__all__ = [ 

37 "Self", 

38 "TypeGuard", 

39 "TypeIs", 

40]