Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/zmq/sugar/version.py: 81%

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

27 statements  

1"""PyZMQ and 0MQ version functions.""" 

2 

3# Copyright (C) PyZMQ Developers 

4# Distributed under the terms of the Modified BSD License. 

5from __future__ import annotations 

6 

7import re 

8from re import Match 

9from typing import cast 

10 

11from zmq.backend import zmq_version_info 

12 

13__version__: str = "27.2.0.dev" 

14_version_pat = re.compile(r"(\d+)\.(\d+)\.(\d+)(.*)") 

15_match = cast(Match, _version_pat.match(__version__)) 

16_version_groups = _match.groups() 

17 

18VERSION_MAJOR = int(_version_groups[0]) 

19VERSION_MINOR = int(_version_groups[1]) 

20VERSION_PATCH = int(_version_groups[2]) 

21VERSION_EXTRA = _version_groups[3].lstrip(".") 

22 

23version_info: tuple[int, int, int] | tuple[int, int, int, float] = ( 

24 VERSION_MAJOR, 

25 VERSION_MINOR, 

26 VERSION_PATCH, 

27) 

28 

29if VERSION_EXTRA: 

30 version_info = ( 

31 VERSION_MAJOR, 

32 VERSION_MINOR, 

33 VERSION_PATCH, 

34 float('inf'), 

35 ) 

36 

37__revision__: str = '' 

38 

39 

40def pyzmq_version() -> str: 

41 """return the version of pyzmq as a string""" 

42 if __revision__: 

43 return '+'.join([__version__, __revision__[:6]]) 

44 else: 

45 return __version__ 

46 

47 

48def pyzmq_version_info() -> tuple[int, int, int] | tuple[int, int, int, float]: 

49 """return the pyzmq version as a tuple of at least three numbers 

50 

51 If pyzmq is a development version, `inf` will be appended after the third integer. 

52 """ 

53 return version_info 

54 

55 

56def zmq_version() -> str: 

57 """return the version of libzmq as a string""" 

58 return "{}.{}.{}".format(*zmq_version_info()) 

59 

60 

61__all__ = [ 

62 'zmq_version', 

63 'zmq_version_info', 

64 'pyzmq_version', 

65 'pyzmq_version_info', 

66 '__version__', 

67 '__revision__', 

68]