@@ -297,7 +297,7 @@ def __init__(self, section):
297297
298298 def interpolate (self , key , value ):
299299 # short-cut
300- if not self ._cookie in value :
300+ if self ._cookie not in value :
301301 return value
302302
303303 def recursive_interpolate (key , value , section , backtrail ):
@@ -528,7 +528,7 @@ def _interpolate(self, key, value):
528528 except AttributeError :
529529 # not yet: first time running _interpolate(), so pick the engine
530530 name = self .main .interpolation
531- if name == True : # note that "if name:" would be incorrect here
531+ if name is True : # note that "if name:" would be incorrect here
532532 # backwards-compatibility: interpolation=True means use default
533533 name = DEFAULT_INTERPOLATION
534534 name = name .lower () # so that "Template", "template", etc. all work
@@ -948,9 +948,9 @@ def as_bool(self, key):
948948 0
949949 """
950950 val = self [key ]
951- if val == True :
951+ if val is True :
952952 return True
953- elif val == False :
953+ elif val is False :
954954 return False
955955 else :
956956 try :
@@ -2237,7 +2237,7 @@ def validate_entry(entry, spec, val, missing, ret_true, ret_false):
22372237 if entry in ('__many__' , '___many___' ):
22382238 # reserved names
22392239 continue
2240- if (not entry in section .scalars ) or (entry in section .defaults ):
2240+ if (entry not in section .scalars ) or (entry in section .defaults ):
22412241 # missing entries
22422242 # or entries from defaults
22432243 missing = True
@@ -2300,9 +2300,9 @@ def validate_entry(entry, spec, val, missing, ret_true, ret_false):
23002300 section .inline_comments [entry ] = configspec .inline_comments .get (entry , '' )
23012301 check = self .validate (validator , preserve_errors = preserve_errors , copy = copy , section = section [entry ])
23022302 out [entry ] = check
2303- if check == False :
2303+ if check is False :
23042304 ret_true = False
2305- elif check == True :
2305+ elif check is True :
23062306 ret_false = False
23072307 else :
23082308 ret_true = False
@@ -2421,15 +2421,15 @@ def flatten_errors(cfg, res, levels=None, results=None):
24212421 # first time called
24222422 levels = []
24232423 results = []
2424- if res == True :
2424+ if res is True :
24252425 return sorted (results )
2426- if res == False or isinstance (res , Exception ):
2426+ if res is False or isinstance (res , Exception ):
24272427 results .append ((levels [:], None , res ))
24282428 if levels :
24292429 levels .pop ()
24302430 return sorted (results )
24312431 for (key , val ) in list (res .items ()):
2432- if val == True :
2432+ if val is True :
24332433 continue
24342434 if isinstance (cfg .get (key ), dict ):
24352435 # Go down one level
0 commit comments