Skip to content

Commit 108713b

Browse files
committedFeb 25, 2019
Update to fix mypy errors
1 parent 3ffe08f commit 108713b

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed
 

‎LICENSE

100755100644
File mode changed.

‎isort/finders.py

+18-9
Original file line numberDiff line numberDiff line change
@@ -326,22 +326,31 @@ class FindersManager(object):
326326
PipfileFinder,
327327
RequirementsFinder,
328328
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:
332337
self.verbose = config.get('verbose', False)
338+
if finders is not None:
339+
self.finders = finders
333340

334341
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:
337345
try:
338-
self.finders.append(finder(config, sections))
346+
register_finders.append(finder_cls(config, sections))
339347
except Exception as exception:
340348
# if one finder fails to instantiate isort can continue using the rest
341349
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)
345354

346355
def find(self, module_name: str) -> Optional[str]:
347356
for finder in self.finders:

0 commit comments

Comments
 (0)
Please sign in to comment.