44from  collections .abc  import  Iterable , MutableMapping 
55from  collections  import  defaultdict 
66from  hashlib  import  sha1 , sha256 
7- 
7+ from   enum   import   Enum 
88from  deepdiff .helper  import  (strings , numbers , unprocessed , not_hashed , add_to_frozen_set ,
99                             convert_item_or_items_into_set_else_none , get_doc ,
1010                             convert_item_or_items_into_compiled_regexes_else_none ,
2727INDEX_VS_ATTRIBUTE  =  ('[%s]' , '.%s' )
2828
2929
30+ class  BoolObj (Enum ):
31+     TRUE  =  1 
32+     FALSE  =  0 
33+ 
34+ 
3035def  prepare_string_for_hashing (obj , ignore_string_type_changes = False , ignore_string_case = False ):
3136    """ 
3237    Clean type conversions 
@@ -259,6 +264,9 @@ def _prep_iterable(self, obj, parent, parents_ids=EMPTY_FROZENSET):
259264
260265        return  result 
261266
267+     def  _prep_bool (self , obj ):
268+         return  BoolObj .TRUE  if  obj  else  BoolObj .FALSE 
269+ 
262270    def  _prep_number (self , obj ):
263271        type_  =  "number"  if  self .ignore_numeric_type_changes  else  obj .__class__ .__name__ 
264272        if  self .significant_digits  is  not None :
@@ -282,15 +290,19 @@ def _prep_tuple(self, obj, parent, parents_ids):
282290    def  _hash (self , obj , parent , parents_ids = EMPTY_FROZENSET ):
283291        """The main diff method""" 
284292
293+         if  isinstance (obj , bool ):
294+             obj  =  self ._prep_bool (obj )
295+             result  =  None 
296+         else :
297+             result  =  not_hashed 
298+ 
285299        try :
286300            result  =  self [obj ]
287301        except  (TypeError , KeyError ):
288302            pass 
289303        else :
290304            return  result 
291305
292-         result  =  not_hashed 
293- 
294306        if  self ._skip_this (obj , parent ):
295307            return 
296308
@@ -314,6 +326,8 @@ def _hash(self, obj, parent, parents_ids=EMPTY_FROZENSET):
314326        elif  isinstance (obj , Iterable ):
315327            result  =  self ._prep_iterable (obj = obj , parent = parent , parents_ids = parents_ids )
316328
329+         elif  obj  in  {BoolObj .TRUE , BoolObj .FALSE }:
330+             result  =  'bool:true'  if  obj  is  BoolObj .TRUE  else  'bool:false' 
317331        else :
318332            result  =  self ._prep_obj (obj = obj , parent = parent , parents_ids = parents_ids )
319333
0 commit comments