2828from typing import Callable , Dict , List , Optional , Tuple , Union
2929
3030from .box import TextBox
31- from .utils import (CursesTextAttributesConstants ,
31+ from .utils import (CursesTextAttributesConstant ,
32+ CursesTextAttributesConstants ,
3233 TextAttributes ,
3334 _make_chunk )
3435
@@ -43,11 +44,12 @@ class DialogBox(TextBox):
4344 to ``"►"``.
4445 :type end_dialog_indicator: str
4546
46- :key kwargs: Keyword arguments correspond to the instance attributes of
47- ``TextBox``.
47+ :key kwargs: Keyword arguments correspond to the instance attributes
48+ of ``TextBox``.
4849
4950 .. NOTE::
50- This class inherits all the methods and attributes of ``TextBox``.
51+ This class inherits all the methods and attributes of
52+ ``TextBox``.
5153
5254 .. WARNING::
5355 Parameters ``downtime_chars`` and ``downtime_chars_delay`` do
@@ -78,8 +80,8 @@ def __exit__(self, type, value, traceback):
7880 def _display_end_dialog_indicator (
7981 self ,
8082 stdscr ,
81- text_attr : Optional [ Union [ Tuple [ CursesTextAttributesConstants ], List [ CursesTextAttributesConstants ]]] = (
82- curses . A_BOLD , curses .A_BLINK )):
83+ text_attr : CursesTextAttributesConstants = (curses . A_BOLD ,
84+ curses .A_BLINK )):
8385 """Displays an end of dialog indicator in the lower right corner
8486 of textbox.
8587
@@ -89,7 +91,7 @@ def _display_end_dialog_indicator(
8991 :param text_attr: Text attributes of
9092 ``end_dialog_indicator`` method. This defaults to
9193 ``(curses.A_BOLD, curses.A_BLINK)``.
92- :type text_attr: Optional[Union[tuple[ CursesTextAttributesConstants],list[CursesTextAttributesConstants]]]
94+ :type text_attr: CursesTextAttributesConstants
9395 """
9496 if self .end_dialog_indicator_char :
9597 with TextAttributes (stdscr , * text_attr ):
@@ -102,15 +104,13 @@ def char_by_char(
102104 stdscr ,
103105 text : str ,
104106 colors_pair_nb : int = 0 ,
105- text_attr : Union [CursesTextAttributesConstants ,
106- Tuple [CursesTextAttributesConstants ],
107- List [CursesTextAttributesConstants ]] = (),
108- words_attr : Union [Dict [Tuple [str ], CursesTextAttributesConstants ],
109- Dict [Tuple [str ],
110- Tuple [CursesTextAttributesConstants ]]] = {},
107+ text_attr : Union [CursesTextAttributesConstant ,
108+ CursesTextAttributesConstants ] = (),
109+ words_attr : Union [Dict [Tuple [str ], CursesTextAttributesConstant ],
110+ Dict [Tuple [str ], CursesTextAttributesConstants ]] = {},
111111 flash_screen : bool = False ,
112112 delay : Union [int , float ] = .04 ,
113- random_delay : Tuple [float , float ] = (0 , 0 ),
113+ random_delay : Union [ Tuple [int , float ], List [ int , float ] ] = (0 , 0 ),
114114 callback : Callable = lambda : None ,
115115 cargs : Union [Tuple , List ] = ()):
116116 """Writes the given text character by character in the current
@@ -129,40 +129,40 @@ def char_by_char(
129129 corresponding to the pair of white color on black
130130 background initialized by ``curses``). This defaults to
131131 ``0``.
132- :type colors_pair_nb: Optional[ int]
132+ :type colors_pair_nb: int
133133
134134 :param text_attr: Dialog box curses text attributes. It should
135135 be a single curses text attribute or a tuple of curses text
136136 attribute. This defaults an empty tuple.
137- :type text_attr: Optional[ Union[CursesTextAttributesConstants,tuple[ CursesTextAttributesConstants],list[CursesTextAttributesConstants]] ]
137+ :type text_attr: Union[CursesTextAttributesConstant, CursesTextAttributesConstants]
138138
139139 :param words_attr: This defaults to an empty dictionary.
140- :type words_atttr: Union[Dict[tuple [str],CursesTextAttributesConstants],Dict[tuple [str],tuple[ CursesTextAttributesConstants] ]]
140+ :type words_atttr: Union[dict[Tuple [str], CursesTextAttributesConstant],dict[Tuple [str], CursesTextAttributesConstants]]
141141
142142 :param flash_screen: Allows or not to flash screen with a short
143143 light effect done before writing the first character by
144144 ``flash`` function from ``curses`` module. This defaults to
145145 ``False``.
146- :type flash_screen: Optional[ bool]
146+ :type flash_screen: bool
147147
148148 :param delay: Waiting time between the writing of each character
149149 of text in second. This defaults to ``0.04``.
150- :type delay: Optional[ Union[int, float] ]
150+ :type delay: Union[int, float]
151151
152152 :param random_delay: Waiting time between the writing of each
153153 character in seconds where time waited is a random number
154154 generated in ``random_delay`` interval. This defaults to
155155 ``(0, 0)``.
156- :type random_delay: Optional [tuple[float, flot ],list[float , float]]
156+ :type random_delay: Union [tuple[int, float ],list[int , float]]
157157
158158 :param callback: Callable called after writing a character and
159159 the delay time has elapsed. This defaults to a lambda which
160160 do nothing.
161- :type callback: Optional[ Callable]
161+ :type callback: Callable
162162
163163 :param cargs: All the arguments that will be passed to callback.
164164 This defaults to an empty tuple.
165- :type cargs: Optional[ Union[tuple[Any] ,list[Any]] ]
165+ :type cargs: Union[tuple,list]
166166
167167 .. NOTE::
168168 Method flow:
@@ -182,7 +182,8 @@ def char_by_char(
182182 If the volume of text displayed is too large to be contained
183183 in a dialog box, text will be automatically cut into
184184 paragraphs using ``textwrap.wrap`` function. See
185- `textwrap module documentation <https://docs.python.org/fr/3.8/library/textwrap.html#textwrap.wrap>`_.
185+ `textwrap module documentation
186+ <https://docs.python.org/fr/3.8/library/textwrap.html#textwrap.wrap>`_.
186187 for more information of the behavior of text wrap.
187188
188189 .. WARNING::
@@ -248,15 +249,13 @@ def word_by_word(
248249 text : str ,
249250 colors_pair_nb : int = 0 ,
250251 cut_char : str = " " ,
251- text_attr : Union [CursesTextAttributesConstants ,
252- Tuple [CursesTextAttributesConstants ],
253- List [CursesTextAttributesConstants ]] = (),
254- words_attr : Union [Dict [Tuple [str ], CursesTextAttributesConstants ],
255- Dict [Tuple [str ],
256- Tuple [CursesTextAttributesConstants ]]] = {},
252+ text_attr : Union [CursesTextAttributesConstant ,
253+ CursesTextAttributesConstants ] = (),
254+ words_attr : Union [Dict [Tuple [str ], CursesTextAttributesConstant ],
255+ Dict [Tuple [str ], CursesTextAttributesConstants ]] = {},
257256 flash_screen : bool = False ,
258257 delay : Union [int , float ] = .15 ,
259- random_delay : Tuple [float , float ] = (0 , 0 ),
258+ random_delay : Union [ Tuple [int , float ], List [ int , float ] ] = (0 , 0 ),
260259 callback : Callable = lambda : None ,
261260 cargs : Union [Tuple , List ] = ()):
262261 """Writes the given text word by word at position in the current
@@ -275,15 +274,15 @@ def word_by_word(
275274 the text. The number zero corresponding to the pair of
276275 white color on black background initialized by ``curses``).
277276 This defaults to ``0``.
278- :type colors_pair_nb: Optional[ int]
277+ :type colors_pair_nb: int
279278
280279 :param text_attr: Dialog box curses text attributes. It should
281280 be a single curses text attribute or a tuple of curses text
282281 attribute. This defaults an empty tuple.
283- :type text_attr: Optional[ Union[CursesTextAttributesConstants,tuple[ CursesTextAttributesConstants],list[CursesTextAttributesConstants]] ]
282+ :type text_attr: Union[CursesTextAttributesConstant, CursesTextAttributesConstants]
284283
285284 :param words_attr: This defaults to an empty dictionary.
286- :type words_atttr: Union[Dict[tuple [str],CursesTextAttributesConstants],Dict[tuple [str],tuple[ CursesTextAttributesConstants] ]]
285+ :type words_atttr: Union[dict[Tuple [str], CursesTextAttributesConstant],dict[Tuple [str], CursesTextAttributesConstants]]
287286
288287 :param cut_char: The delimiter according which to split the text
289288 in word. This defaults to ``" "``.
@@ -293,26 +292,26 @@ def word_by_word(
293292 light effect done before writing the first character by
294293 ``flash`` function from ``curses`` module. This defaults to
295294 ``False``.
296- :type flash_screen: Optional[ bool]
295+ :type flash_screen: bool
297296
298297 :param delay: Waiting time between the writing of each word of
299298 ``text`` in second. This defaults to ``0.15``.
300- :type delay: Optional[ Union[int, float] ]
299+ :type delay: Union[int, float]
301300
302301 :param random_delay: Waiting time between the writing of each
303302 word in seconds where time waited is a random number
304303 generated in ``random_delay`` interval. This defaults to
305304 ``(0, 0)``.
306- :type random_delay: Optional [tuple[float , float],list[float , float]]
305+ :type random_delay: Union [tuple[int , float],list[int , float]]
307306
308307 :param callback: Callable called after writing a word and the
309308 delay time has elapsed. This defaults to a lambda which do
310309 nothing.
311- :type callback: Optional[ Callable]
310+ :type callback: Callable
312311
313312 :param cargs: All the arguments that will be passed to callback.
314313 This defaults to an empty tuple.
315- :type cargs: Optional[ Union[tuple[Any] ,list[Any]] ]
314+ :type cargs: Union[tuple,list]
316315
317316 .. NOTE::
318317 Method flow:
@@ -333,7 +332,8 @@ def word_by_word(
333332 If the volume of text displayed is too large to be contained
334333 in a dialog box, text will be automatically cut into
335334 paragraphs using ``textwrap.wrap`` function. See
336- `textwrap module documentation <https://docs.python.org/fr/3.8/library/textwrap.html#textwrap.wrap>`_
335+ `textwrap module documentation
336+ <https://docs.python.org/fr/3.8/library/textwrap.html#textwrap.wrap>`_
337337 for more information of the behavior of text wrap.
338338
339339 .. WARNING::
0 commit comments