File tree Expand file tree Collapse file tree 1 file changed +10
-8
lines changed
packages/python/plotly/plotly Expand file tree Collapse file tree 1 file changed +10
-8
lines changed Original file line number Diff line number Diff line change @@ -34,14 +34,16 @@ def _len_dict_item(item):
3434 know the length of the resulting string when printing we might need to
3535 convert to a string before calling len on it.
3636 """
37- if type (item ) == type (str ()):
38- return len (item )
39- elif type (item ) == type (int ()):
40- return len ("%d" % (item ,))
41- else :
42- raise ValueError (
43- "Cannot find string length of an item that is neither a string nor an integer."
44- )
37+ try :
38+ l = len (item )
39+ except TypeError :
40+ try :
41+ l = len ("%d" % (item ,))
42+ except TypeError :
43+ raise ValueError (
44+ "Cannot find string length of an item that is not string-like nor an integer."
45+ )
46+ return l
4547
4648
4749def _str_to_dict_path_full (key_path_str ):
You can’t perform that action at this time.
0 commit comments