MCPcopy
hub / github.com/fastapi/typer / Result

Class Result

typer/testing.py:78–125  ·  view source on GitHub ↗

Holds the captured result of an invoked CLI script.

Source from the content-addressed store, hash-verified

76
77
78class Result:
79 """Holds the captured result of an invoked CLI script."""
80
81 def __init__(
82 self,
83 runner: "CliRunner",
84 stdout_bytes: bytes,
85 stderr_bytes: bytes,
86 output_bytes: bytes,
87 return_value: Any,
88 exit_code: int,
89 exception: BaseException | None,
90 exc_info: tuple[type[BaseException], BaseException, TracebackType]
91 | None = None,
92 ):
93 self.runner = runner
94 self.stdout_bytes = stdout_bytes
95 self.stderr_bytes = stderr_bytes
96 self.output_bytes = output_bytes
97 self.return_value = return_value
98 self.exit_code = exit_code
99 self.exception = exception
100 self.exc_info = exc_info
101
102 @property
103 def output(self) -> str:
104 """The terminal output as unicode string, as the user would see it."""
105 return self.output_bytes.decode(self.runner.charset, "replace").replace(
106 "\r\n", "\n"
107 )
108
109 @property
110 def stdout(self) -> str:
111 """The standard output as unicode string."""
112 return self.stdout_bytes.decode(self.runner.charset, "replace").replace(
113 "\r\n", "\n"
114 )
115
116 @property
117 def stderr(self) -> str:
118 """The standard error as unicode string."""
119 return self.stderr_bytes.decode(self.runner.charset, "replace").replace(
120 "\r\n", "\n"
121 )
122
123 def __repr__(self) -> str:
124 exc_str = repr(self.exception) if self.exception else "okay"
125 return f"<{type(self).__name__} {exc_str}>"
126
127
128class CliRunner:

Callers 1

invokeMethod · 0.85

Calls

no outgoing calls

Tested by 1

invokeMethod · 0.68

Used in the wild real call sites across dependent graphs

searching dependent graphs…