@@ -326,22 +326,31 @@ class FindersManager(object):
326
326
PipfileFinder ,
327
327
RequirementsFinder ,
328
328
DefaultFinder ,
329
- )
330
-
331
- def __init__ (self , config : Mapping [str , Any ], sections : Any , finders : Optional [Iterable [BaseFinder ]]= None ):
329
+ ) # type: Sequence[Type[BaseFinder]]
330
+
331
+ def __init__ (
332
+ self ,
333
+ config : Mapping [str , Any ],
334
+ sections : Any ,
335
+ finders : Optional [Sequence [Type [BaseFinder ]]] = None
336
+ ) -> None :
332
337
self .verbose = config .get ('verbose' , False )
338
+ if finders is not None :
339
+ self .finders = finders
333
340
334
341
finders = self ._default_finders_classes if finders is None else finders
335
- self .finders = []
336
- for finder in finders :
342
+
343
+ register_finders = []
344
+ for finder_cls in finders :
337
345
try :
338
- self . finders . append (finder (config , sections ))
346
+ register_finders . append (finder_cls (config , sections ))
339
347
except Exception as exception :
340
348
# if one finder fails to instantiate isort can continue using the rest
341
349
if self .verbose :
342
- print ('{} encountered an error ({}) during instantiation and cannot be used' .format (finder .__name__ ,
343
- str (exception )))
344
- self .finders = tuple (self .finders )
350
+ print ('{} encountered an error ({}) during instantiation '
351
+ ' and cannot be used' .format (finder_cls .__name__ , str (exception )))
352
+
353
+ self .finders = tuple (register_finders )
345
354
346
355
def find (self , module_name : str ) -> Optional [str ]:
347
356
for finder in self .finders :
0 commit comments