MCPcopy
hub / github.com/pallets/click / make_input_stream

Function make_input_stream

src/click/testing.py:211–228  ·  view source on GitHub ↗
(
    input: str | bytes | t.IO[t.Any] | None, charset: str
)

Source from the content-addressed store, hash-verified

209
210
211def make_input_stream(
212 input: str | bytes | t.IO[t.Any] | None, charset: str
213) -> t.BinaryIO:
214 # Is already an input stream.
215 if hasattr(input, "read"):
216 rv = _find_binary_reader(t.cast("t.IO[t.Any]", input))
217
218 if rv is not None:
219 return rv
220
221 raise TypeError("Could not find binary reader for input stream.")
222
223 if input is None:
224 input = b""
225 elif isinstance(input, str):
226 input = input.encode(charset)
227
228 return io.BytesIO(input)
229
230
231class Result:

Callers 1

isolationMethod · 0.85

Calls 1

_find_binary_readerFunction · 0.85

Tested by

no test coverage detected