diff options
| author | Ruben Herold <ruben@puettmann.net> | 2026-08-11 22:25:10 +0200 |
|---|---|---|
| committer | Ruben Herold <ruben@puettmann.net> | 2026-08-11 22:25:10 +0200 |
| commit | 82c8f97d7ea5d49694b6256a388ba17c8a0cd58e (patch) | |
| tree | d38e6e8127751aa68ccfcda346b31a6905a61464 | |
| parent | b069ded58275ccb19d01b7dfa9944f27f0b4bb4d (diff) | |
| download | vyos-1x-82c8f97d7ea5d49694b6256a388ba17c8a0cd58e.tar.gz vyos-1x-82c8f97d7ea5d49694b6256a388ba17c8a0cd58e.zip | |
utils: T9185: document ask_yes_no() non-tty default behavior
The docstring said the function always prompts via input(), but the
non-TTY fast-path added in this branch returns default without
prompting. Document that.
Flagged by Copilot review on PR #5390.
| -rw-r--r-- | python/vyos/utils/io.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/python/vyos/utils/io.py b/python/vyos/utils/io.py index 13ef8709a..360fc1ffb 100644 --- a/python/vyos/utils/io.py +++ b/python/vyos/utils/io.py @@ -55,7 +55,11 @@ def ask_input(question, default='', numeric_only=False, valid_responses=[], return response def ask_yes_no(question, default=False) -> bool: - """Ask a yes/no question via input() and return their answer.""" + """Ask a yes/no question via input() and return their answer. + + If stdin is not a TTY (e.g. non-interactive scripts), returns + default without prompting. + """ from sys import stdin, stdout if not stdin.isatty(): |
