Coverage for /pythoncovmergedfiles/medio/medio/usr/local/lib/python3.11/site-packages/argcomplete/io.py: 50%
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
Shortcuts on this page
r m x toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
1from __future__ import annotations
3import contextlib
4import os
5import sys
6from collections.abc import Generator
8_DEBUG = "_ARC_DEBUG" in os.environ
10debug_stream = sys.stderr
13def debug(*args: object) -> None:
14 if _DEBUG:
15 print(file=debug_stream, *args)
18@contextlib.contextmanager
19def mute_stdout() -> Generator[None]:
20 stdout = sys.stdout
21 sys.stdout = open(os.devnull, "w")
22 try:
23 yield
24 finally:
25 sys.stdout = stdout
28@contextlib.contextmanager
29def mute_stderr() -> Generator[None]:
30 stderr = sys.stderr
31 sys.stderr = open(os.devnull, "w")
32 try:
33 yield
34 finally:
35 sys.stderr.close()
36 sys.stderr = stderr
39def warn(*args: object) -> None:
40 """
41 Prints **args** to standard error when running completions. This will interrupt the user's command line interaction;
42 use it to indicate an error condition that is preventing your completer from working.
43 """
44 print(file=debug_stream)
45 print(file=debug_stream, *args)