@@ -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,11 +204,11 @@ 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 :
211- translate = escape_chars
211+ translate = escape_chars # type: ignore[assignment]
212212 escape_chars = list (escape_chars .keys ())
213213 else :
214214 escape_chars = escape_chars or ()
@@ -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