MCPcopy Index your code
hub / github.com/python-cmd2/cmd2 / _is_tty_session

Method _is_tty_session

cmd2/cmd2.py:3422–3433  ·  view source on GitHub ↗

Determine if the session supports full terminal interactions. Returns True if the session is attached to a real TTY or a virtual terminal (like PipeInput in tests). Returns False if the session is running in a headless environment (DummyInput).

(session: PromptSession[str])

Source from the content-addressed store, hash-verified

3420
3421 @staticmethod
3422 def _is_tty_session(session: PromptSession[str]) -> bool:
3423 """Determine if the session supports full terminal interactions.
3424
3425 Returns True if the session is attached to a real TTY or a virtual
3426 terminal (like PipeInput in tests). Returns False if the session is
3427 running in a headless environment (DummyInput).
3428 """
3429 # Validate against the session's assigned input driver rather than sys.stdin.
3430 # This respects the fallback logic in _create_main_session() and allows unit
3431 # tests to inject PipeInput for programmatic interaction even if paired with
3432 # a DummyOutput.
3433 return not isinstance(session.input, DummyInput)
3434
3435 def _read_raw_input(
3436 self,

Callers 2

_read_raw_inputMethod · 0.95
selectMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected