Skip to content

Commit 3e9d00b

Browse files
authored
BUG: pretty print all Mappings, not just dicts
This was discovered in ibis-project/ibis#8693
1 parent aa3e949 commit 3e9d00b

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

pandas/io/formats/printing.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -187,8 +187,8 @@ def pprint_thing(
187187
_nest_lvl : internal use only. pprint_thing() is mutually-recursive
188188
with pprint_sequence, this argument is used to keep track of the
189189
current nesting level, and limit it.
190-
escape_chars : list or dict, optional
191-
Characters to escape. If a dict is passed the values are the
190+
escape_chars : list[str] or Mapping[str, str], optional
191+
Characters to escape. If a Mapping is passed the values are the
192192
replacements
193193
default_escapes : bool, default False
194194
Whether the input escape characters replaces or adds to the defaults
@@ -204,7 +204,7 @@ def as_escaped_string(
204204
thing: Any, escape_chars: EscapeChars | None = escape_chars
205205
) -> str:
206206
translate = {"\t": r"\t", "\n": r"\n", "\r": r"\r"}
207-
if isinstance(escape_chars, dict):
207+
if isinstance(escape_chars, Mapping):
208208
if default_escapes:
209209
translate.update(escape_chars)
210210
else:
@@ -220,7 +220,7 @@ def as_escaped_string(
220220

221221
if hasattr(thing, "__next__"):
222222
return str(thing)
223-
elif isinstance(thing, dict) and _nest_lvl < get_option(
223+
elif isinstance(thing, Mapping) and _nest_lvl < get_option(
224224
"display.pprint_nest_depth"
225225
):
226226
result = _pprint_dict(

0 commit comments

Comments
 (0)