@@ -276,7 +276,7 @@ def _ToolAppend(tools, tool_name, setting, value, only_if_unset=False):
276276def _ToolSetOrAppend (tools , tool_name , setting , value , only_if_unset = False ):
277277 # TODO(bradnelson): ugly hack, fix this more generally!!!
278278 if "Directories" in setting or "Dependencies" in setting :
279- if type (value ) == str :
279+ if isinstance (value , str ) :
280280 value = value .replace ("/" , "\\ " )
281281 else :
282282 value = [i .replace ("/" , "\\ " ) for i in value ]
@@ -288,7 +288,7 @@ def _ToolSetOrAppend(tools, tool_name, setting, value, only_if_unset=False):
288288 if tool .get (setting ):
289289 if only_if_unset :
290290 return
291- if type (tool [setting ]) == list and type (value ) == list :
291+ if isinstance (tool [setting ], list ) and isinstance (value , list ) :
292292 tool [setting ] += value
293293 else :
294294 raise TypeError (
@@ -1423,7 +1423,7 @@ def _ConvertToolsToExpectedForm(tools):
14231423 # Collapse settings with lists.
14241424 settings_fixed = {}
14251425 for setting , value in settings .items ():
1426- if type (value ) == list :
1426+ if isinstance (value , list ) :
14271427 if (
14281428 tool == "VCLinkerTool" and setting == "AdditionalDependencies"
14291429 ) or setting == "AdditionalOptions" :
@@ -1816,7 +1816,7 @@ def _DictsToFolders(base_path, bucket, flat):
18161816 # Convert to folders recursively.
18171817 children = []
18181818 for folder , contents in bucket .items ():
1819- if type (contents ) == dict :
1819+ if isinstance (contents , dict ) :
18201820 folder_children = _DictsToFolders (
18211821 os .path .join (base_path , folder ), contents , flat
18221822 )
@@ -1838,9 +1838,10 @@ def _CollapseSingles(parent, node):
18381838 # Recursively explorer the tree of dicts looking for projects which are
18391839 # the sole item in a folder which has the same name as the project. Bring
18401840 # such projects up one level.
1841- if type (node ) == dict and len (node ) == 1 and next (iter (node )) == parent + ".vcproj" :
1841+ if (isinstance (node , dict ) and len (node ) == 1 and
1842+ next (iter (node )) == parent + ".vcproj" ):
18421843 return node [next (iter (node ))]
1843- if type (node ) != dict :
1844+ if not isinstance (node , dict ) :
18441845 return node
18451846 for child in node :
18461847 node [child ] = _CollapseSingles (child , node [child ])
@@ -1860,7 +1861,7 @@ def _GatherSolutionFolders(sln_projects, project_objects, flat):
18601861 # Walk down from the top until we hit a folder that has more than one entry.
18611862 # In practice, this strips the top-level "src/" dir from the hierarchy in
18621863 # the solution.
1863- while len (root ) == 1 and type (root [next (iter (root ))]) == dict :
1864+ while len (root ) == 1 and isinstance (root [next (iter (root ))], dict ) :
18641865 root = root [next (iter (root ))]
18651866 # Collapse singles.
18661867 root = _CollapseSingles ("" , root )
@@ -3441,7 +3442,7 @@ def _FinalizeMSBuildSettings(spec, configuration):
34413442
34423443
34433444def _GetValueFormattedForMSBuild (tool_name , name , value ):
3444- if type (value ) == list :
3445+ if isinstance (value , list ) :
34453446 # For some settings, VS2010 does not automatically extends the settings
34463447 # TODO(jeanluc) Is this what we want?
34473448 if name in [
0 commit comments