Coverage for /var/srv/projects/api.amasfac.comuna18.com/tmp/venv/lib/python3.9/site-packages/openpyxl/compat/__init__.py: 73%

27 statements  

« prev     ^ index     » next       coverage.py v6.4.4, created at 2023-07-17 14:22 -0600

1# Copyright (c) 2010-2022 openpyxl 

2 

3from .numbers import NUMERIC_TYPES 

4from .strings import safe_string 

5 

6import warnings 

7from functools import wraps 

8import inspect 

9 

10 

11class DummyCode: 

12 

13 pass 

14 

15 

16# from https://github.com/tantale/deprecated/blob/master/deprecated/__init__.py 

17# with an enhancement to update docstrings of deprecated functions 

18string_types = (type(b''), type(u'')) 

19def deprecated(reason): 

20 

21 if isinstance(reason, string_types): 21 ↛ 50line 21 didn't jump to line 50, because the condition on line 21 was never false

22 

23 def decorator(func1): 

24 

25 if inspect.isclass(func1): 25 ↛ 26line 25 didn't jump to line 26, because the condition on line 25 was never true

26 fmt1 = "Call to deprecated class {name} ({reason})." 

27 else: 

28 fmt1 = "Call to deprecated function {name} ({reason})." 

29 

30 @wraps(func1) 

31 def new_func1(*args, **kwargs): 

32 #warnings.simplefilter('default', DeprecationWarning) 

33 warnings.warn( 

34 fmt1.format(name=func1.__name__, reason=reason), 

35 category=DeprecationWarning, 

36 stacklevel=2 

37 ) 

38 return func1(*args, **kwargs) 

39 

40 # Enhance docstring with a deprecation note 

41 deprecationNote = "\n\n.. note::\n Deprecated: " + reason 

42 if new_func1.__doc__: 

43 new_func1.__doc__ += deprecationNote 

44 else: 

45 new_func1.__doc__ = deprecationNote 

46 return new_func1 

47 

48 return decorator 

49 

50 elif inspect.isclass(reason) or inspect.isfunction(reason): 

51 raise TypeError("Reason for deprecation must be supplied") 

52 

53 else: 

54 raise TypeError(repr(type(reason)))