Skip to content

Commit c724d37

Browse files
committed
Updated docs and stubs for terminal_colours
1 parent 1ed1ebe commit c724d37

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

domdf_python_tools/terminal_colours.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,8 @@ def strip_ansi(value: str) -> str:
126126
Strip ANSI colour codes from the given string to return a plaintext output.
127127
128128
:param value:
129+
130+
.. versionadded:: 1.1.0
129131
"""
130132

131133
return _ansi_re.sub("", value)

domdf_python_tools/terminal_colours.pyi

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ See: http://en.wikipedia.org/wiki/ANSI_escape_code
2828
# Based on colorama
2929
# https://github.com/tartley/colorama
3030
# Copyright Jonathan Hartley 2013
31-
# Distrubuted under the BSD 3-Clause license.
31+
# Distributed under the BSD 3-Clause license.
3232
# | Redistribution and use in source and binary forms, with or without
3333
# | modification, are permitted provided that the following conditions are met:
3434
# |
@@ -64,13 +64,13 @@ from typing import List
6464
# 3rd party
6565
from typing_extensions import Final
6666

67-
CSI: Final[str] = '\033['
68-
OSC: Final[str] = '\033]'
69-
BEL: Final[str] = '\a'
67+
CSI: Final[str]
68+
OSC: Final[str]
69+
BEL: Final[str]
7070

71-
fore_stack: List[str] = []
72-
back_stack: List[str] = []
73-
style_stack: List[str] = []
71+
fore_stack: List[str]
72+
back_stack: List[str]
73+
style_stack: List[str]
7474

7575

7676
def code_to_chars(code) -> str: ...
@@ -79,6 +79,9 @@ def clear_screen(mode: int = 2) -> str: ...
7979
def clear_line(mode: int = 2) -> str: ...
8080

8181

82+
def strip_ansi(value: str) -> str: ...
83+
84+
8285
class Colour(str):
8386
style: str
8487
reset: str
@@ -134,8 +137,8 @@ class AnsiFore(AnsiCodes):
134137

135138
class AnsiBack(AnsiCodes):
136139

137-
_stack = back_stack
138-
_reset = "\033[49m"
140+
_stack: List[str]
141+
_reset: str
139142

140143
BLACK: Colour
141144
RED: Colour
@@ -160,8 +163,8 @@ class AnsiBack(AnsiCodes):
160163

161164
class AnsiStyle(AnsiCodes):
162165

163-
_stack = style_stack
164-
_reset = "\033[22m"
166+
_stack: List[str]
167+
_reset: str
165168

166169
BRIGHT: Colour
167170
DIM: Colour
@@ -173,7 +176,3 @@ Fore = AnsiFore()
173176
Back = AnsiBack()
174177
Style = AnsiStyle()
175178
Cursor = AnsiCursor()
176-
177-
fore_stack.append(Fore.RESET)
178-
back_stack.append(Back.RESET)
179-
style_stack.append(Style.NORMAL)

0 commit comments

Comments
 (0)