Skip to content

Commit 4bef4c3

Browse files
authored
compatibility with python 3.8.6 (#74)
* compatibility with python 3.8.6, fix #73 * uprev
1 parent cd9bdee commit 4bef4c3

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

devtools/ansi.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
MYPY = False
1010
if MYPY:
11-
from typing import Any
11+
from typing import Any, Union
1212

1313

1414
def strip_ansi(value):
@@ -93,15 +93,15 @@ def __call__(self, input: 'Any', *styles: 'Style', reset: bool = True, apply: bo
9393
s = self.styles[s]
9494
except KeyError:
9595
raise ValueError('invalid style "{}"'.format(s))
96-
codes.append(str(s.value))
96+
codes.append(_style_as_int(s.value))
9797

9898
if codes:
9999
r = _ansi_template.format(';'.join(codes)) + text
100100
else:
101101
r = text
102102

103103
if reset:
104-
r += _ansi_template.format(self.reset)
104+
r += _ansi_template.format(_style_as_int(self.reset))
105105
return r
106106

107107
@property
@@ -121,6 +121,13 @@ def __str__(self):
121121
return super().__str__()
122122

123123

124+
def _style_as_int(v: 'Union[Style, int]') -> str:
125+
if isinstance(v, Style):
126+
return str(v.value)
127+
else:
128+
return str(v)
129+
130+
124131
sformat = Style(-1)
125132

126133

devtools/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
__all__ = ('VERSION',)
22

3-
VERSION = '0.6'
3+
VERSION = '0.6.1'

0 commit comments

Comments
 (0)