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

Function get_best_encoding

src/click/_compat.py:48–53  ·  view source on GitHub ↗

Returns the default stream encoding if not found.

(stream: t.IO[t.Any])

Source from the content-addressed store, hash-verified

46
47
48def get_best_encoding(stream: t.IO[t.Any]) -> str:
49 """Returns the default stream encoding if not found."""
50 rv = getattr(stream, "encoding", None) or sys.getdefaultencoding()
51 if is_ascii_encoding(rv):
52 return "utf-8"
53 return rv
54
55
56class _NonClosingTextIOWrapper(io.TextIOWrapper):

Callers 5

_pipepagerFunction · 0.85
_tempfilepagerFunction · 0.85
_nullpagerFunction · 0.85
getcharFunction · 0.85
_make_text_streamFunction · 0.85

Calls 1

is_ascii_encodingFunction · 0.85

Tested by

no test coverage detected