@@ -187,8 +187,8 @@ def pprint_thing(
187
187
_nest_lvl : internal use only. pprint_thing() is mutually-recursive
188
188
with pprint_sequence, this argument is used to keep track of the
189
189
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
192
192
replacements
193
193
default_escapes : bool, default False
194
194
Whether the input escape characters replaces or adds to the defaults
@@ -204,7 +204,7 @@ def as_escaped_string(
204
204
thing : Any , escape_chars : EscapeChars | None = escape_chars
205
205
) -> str :
206
206
translate = {"\t " : r"\t" , "\n " : r"\n" , "\r " : r"\r" }
207
- if isinstance (escape_chars , dict ):
207
+ if isinstance (escape_chars , Mapping ):
208
208
if default_escapes :
209
209
translate .update (escape_chars )
210
210
else :
@@ -220,7 +220,7 @@ def as_escaped_string(
220
220
221
221
if hasattr (thing , "__next__" ):
222
222
return str (thing )
223
- elif isinstance (thing , dict ) and _nest_lvl < get_option (
223
+ elif isinstance (thing , Mapping ) and _nest_lvl < get_option (
224
224
"display.pprint_nest_depth"
225
225
):
226
226
result = _pprint_dict (
0 commit comments