@@ -205,7 +205,7 @@ def _merge_plus(self, data, key, value, prepend=False):
205
205
return
206
206
207
207
# Use the special merge for merging dictionaries
208
- if type (data [key ]) == type (value ) == dict :
208
+ if isinstance (data [key ], dict ) and isinstance (value , dict ) :
209
209
self ._merge_special (data [key ], value )
210
210
return
211
211
@@ -275,13 +275,13 @@ def _merge_minus(self, data, key, value):
275
275
if key not in data :
276
276
return
277
277
# Subtract numbers
278
- if type (data [key ]) == type (value ) in [ int , float ] :
278
+ if isinstance (data [key ], ( int , float )) and isinstance (value , ( int , float )) :
279
279
data [key ] = data [key ] - value
280
280
# Replace matching regular expression with empty string
281
- elif type (data [key ]) == type (value ) == type ( "" ):
281
+ elif isinstance (data [key ], str ) and isinstance (value , str ):
282
282
data [key ] = re .sub (value , '' , data [key ])
283
283
# Remove given values from the parent list
284
- elif type (data [key ]) == type (value ) == list :
284
+ elif isinstance (data [key ], list ) and isinstance (value , list ) :
285
285
data [key ] = [item for item in data [key ] if item not in value ]
286
286
# Remove given key from the parent dictionary
287
287
elif isinstance (data [key ], dict ) and isinstance (value , list ):
@@ -750,10 +750,10 @@ def show(self, brief=False, formatting=None, values=None):
750
750
# List available attributes
751
751
for key , value in sorted (self .data .items ()):
752
752
output += "\n {0}: " .format (utils .color (key , 'green' ))
753
- if isinstance (value , type ( "" ) ):
753
+ if isinstance (value , str ):
754
754
output += value .rstrip ("\n " )
755
755
elif isinstance (value , list ) and all (
756
- [isinstance (item , type ( "" ) ) for item in value ]):
756
+ [isinstance (item , str ) for item in value ]):
757
757
output += utils .listed (value )
758
758
else :
759
759
output += pretty (value )
0 commit comments