@@ -54,7 +54,7 @@ def setup(
5454 title : str = "auto" ,
5555 timestamp : bool = False ,
5656) -> None :
57- """ Configure behavior of message functions.
57+ """Configure behavior of message functions.
5858
5959 :param verbose: Whether :func:`debug` messages should get printed
6060 :param quiet: Hide every message except :func:`warning`, :func:`error`, and
@@ -73,7 +73,7 @@ def _setup(**kwargs: ConfigValue) -> None:
7373
7474
7575class Color :
76- """Represent an ANSI escape sequence """
76+ """Represent an ANSI escape sequence"""
7777
7878 def __init__ (self , name : str , code : str ):
7979 self .name = name
@@ -120,7 +120,7 @@ def __repr__(self) -> str:
120120
121121# Other nice-to-have characters:
122122class UnicodeSequence :
123- """ Represent a sequence containing a color followed by a Unicode symbol """
123+ """Represent a sequence containing a color followed by a Unicode symbol"""
124124
125125 def __init__ (self , color : Color , as_unicode : str , as_ascii : str ):
126126 if os .name == "nt" :
@@ -176,7 +176,7 @@ def write_title_string(mystr: str, fileobj: FileObj) -> None:
176176def process_tokens (
177177 tokens : Sequence [Token ], * , end : str = "\n " , sep : str = " "
178178) -> Tuple [str , str ]:
179- """ Returns two strings from a list of tokens.
179+ """Returns two strings from a list of tokens.
180180 One containing ASCII escape codes, the other
181181 only the 'normal' characters
182182
@@ -238,9 +238,7 @@ def message(
238238 fileobj : FileObj = sys .stdout ,
239239 update_title : bool = False ,
240240) -> None :
241- """ Helper method for error, warning, info, debug
242-
243- """
241+ """Helper method for error, warning, info, debug"""
244242 should_use_colors = colors_enabled (fileobj )
245243 with_color , without_color = process_tokens (tokens , end = end , sep = sep )
246244 if CONFIG ["record" ]:
@@ -252,27 +250,27 @@ def message(
252250
253251
254252def fatal (* tokens : Token , ** kwargs : Any ) -> None :
255- """ Print an error message and call ``sys.exit`` """
253+ """Print an error message and call ``sys.exit``"""
256254 error (* tokens , ** kwargs )
257255 sys .exit (1 )
258256
259257
260258def error (* tokens : Token , ** kwargs : Any ) -> None :
261- """ Print an error message """
259+ """Print an error message"""
262260 tokens = [bold , red , "Error:" ] + list (tokens ) # type: ignore
263261 kwargs ["fileobj" ] = sys .stderr
264262 message (* tokens , ** kwargs )
265263
266264
267265def warning (* tokens : Token , ** kwargs : Any ) -> None :
268- """ Print a warning message """
266+ """Print a warning message"""
269267 tokens = [brown , "Warning:" ] + list (tokens ) # type: ignore
270268 kwargs ["fileobj" ] = sys .stderr
271269 message (* tokens , ** kwargs )
272270
273271
274272def info (* tokens : Token , ** kwargs : Any ) -> None :
275- r""" Print an informative message
273+ r"""Print an informative message
276274
277275 :param tokens: list of `ui` constants or strings, like ``(cli_ui.red, 'this is an error')``
278276 :param sep: separator, defaults to ``' '``
@@ -286,7 +284,7 @@ def info(*tokens: Token, **kwargs: Any) -> None:
286284
287285
288286def info_section (* tokens : Token , ** kwargs : Any ) -> None :
289- """ Print an underlined section name """
287+ """Print an underlined section name"""
290288 # We need to know the length of the section:
291289 process_tokens_kwargs = kwargs .copy ()
292290 process_tokens_kwargs ["color" ] = False
@@ -296,22 +294,22 @@ def info_section(*tokens: Token, **kwargs: Any) -> None:
296294
297295
298296def info_1 (* tokens : Token , ** kwargs : Any ) -> None :
299- """ Print an important informative message """
297+ """Print an important informative message"""
300298 info (bold , blue , "::" , reset , * tokens , ** kwargs )
301299
302300
303301def info_2 (* tokens : Token , ** kwargs : Any ) -> None :
304- """ Print an not so important informative message """
302+ """Print an not so important informative message"""
305303 info (bold , blue , "=>" , reset , * tokens , ** kwargs )
306304
307305
308306def info_3 (* tokens : Token , ** kwargs : Any ) -> None :
309- """ Print an even less important informative message """
307+ """Print an even less important informative message"""
310308 info (bold , blue , "*" , reset , * tokens , ** kwargs )
311309
312310
313311def dot (* , last : bool = False , fileobj : FileObj = sys .stdout ) -> None :
314- """ Print a dot without a newline unless it is the last one.
312+ """Print a dot without a newline unless it is the last one.
315313
316314 Useful when you want to display a progress with very little
317315 knowledge.
@@ -323,7 +321,7 @@ def dot(*, last: bool = False, fileobj: FileObj = sys.stdout) -> None:
323321
324322
325323def info_count (i : int , n : int , * rest : Token , ** kwargs : Any ) -> None :
326- """ Display a counter before the rest of the message.
324+ """Display a counter before the rest of the message.
327325
328326 ``rest`` and ``kwargs`` are passed to :func:`info`
329327
@@ -339,7 +337,7 @@ def info_count(i: int, n: int, *rest: Token, **kwargs: Any) -> None:
339337
340338
341339def info_progress (prefix : str , value : float , max_value : float ) -> None :
342- """ Display info progress in percent.
340+ """Display info progress in percent.
343341
344342 :param value: the current value
345343 :param max_value: the max value
@@ -354,7 +352,7 @@ def info_progress(prefix: str, value: float, max_value: float) -> None:
354352
355353
356354def debug (* tokens : Token , ** kwargs : Any ) -> None :
357- """ Print a debug message.
355+ """Print a debug message.
358356
359357 Messages are shown only when ``CONFIG["verbose"]`` is true
360358 """
@@ -375,9 +373,7 @@ def indent(text: str, num: int = 2) -> str:
375373
376374
377375def tabs (num : int ) -> str :
378- """ Compute a blank tab
379-
380- """
376+ """Compute a blank tab"""
381377 return " " * num
382378
383379
@@ -420,7 +416,7 @@ def info_table(
420416
421417
422418def message_for_exception (exception : Exception , message : str ) -> Sequence [Token ]:
423- """ Returns a tuple suitable for cli_ui.error()
419+ """Returns a tuple suitable for cli_ui.error()
424420 from the given exception.
425421 (Traceback will be part of the message, after
426422 the ``message`` argument)
@@ -443,17 +439,13 @@ def message_for_exception(exception: Exception, message: str) -> Sequence[Token]
443439
444440
445441def read_input () -> str :
446- """ Read input from the user
447-
448- """
442+ """Read input from the user"""
449443 info (green , "> " , end = "" )
450444 return input ()
451445
452446
453447def read_password () -> str :
454- """ Read a password from the user
455-
456- """
448+ """Read a password from the user"""
457449 info (green , "> " , end = "" )
458450 return getpass .getpass (prompt = "" )
459451
@@ -463,8 +455,7 @@ def get_ask_tokens(tokens: Sequence[Token]) -> List[Token]:
463455
464456
465457def ask_string (* question : Token , default : Optional [str ] = None ) -> Optional [str ]:
466- """Ask the user to enter a string.
467- """
458+ """Ask the user to enter a string."""
468459 tokens = get_ask_tokens (question )
469460 if default :
470461 tokens .append ("(%s)" % default )
@@ -476,8 +467,7 @@ def ask_string(*question: Token, default: Optional[str] = None) -> Optional[str]
476467
477468
478469def ask_password (* question : Token ) -> str :
479- """Ask the user to enter a password.
480- """
470+ """Ask the user to enter a password."""
481471 tokens = get_ask_tokens (question )
482472 info (* tokens )
483473 answer = read_password ()
@@ -563,9 +553,7 @@ def ask_yes_no(*question: Token, default: bool = False) -> bool:
563553
564554
565555class Timer :
566- """ Display time taken when executing a list of statements.
567-
568- """
556+ """Display time taken when executing a list of statements."""
569557
570558 def __init__ (self , description : str ):
571559 self .description = description
@@ -591,11 +579,11 @@ def __exit__(self, *unused: Any) -> None:
591579 self .stop ()
592580
593581 def start (self ) -> None :
594- """ Start the timer """
582+ """Start the timer"""
595583 self .start_time = datetime .datetime .now ()
596584
597585 def stop (self ) -> None :
598- """ Stop the timer and emit a nice log """
586+ """Stop the timer and emit a nice log"""
599587 end_time = datetime .datetime .now ()
600588 elapsed_time = end_time - self .start_time
601589 elapsed_seconds = elapsed_time .seconds
@@ -611,7 +599,7 @@ def stop(self) -> None:
611599
612600
613601def did_you_mean (message : str , user_input : str , choices : Sequence [str ]) -> str :
614- """ Given a list of choices and an invalid user input, display the closest
602+ """Given a list of choices and an invalid user input, display the closest
615603 items in the list that match the input.
616604
617605 """
0 commit comments