diff options
-rw-r--r-- | pylint/lint.py | 16 | ||||
-rw-r--r-- | pylint/utils.py | 27 |
2 files changed, 20 insertions, 23 deletions
diff --git a/pylint/lint.py b/pylint/lint.py index 26d79abd7..5cfec9bf7 100644 --- a/pylint/lint.py +++ b/pylint/lint.py @@ -974,9 +974,8 @@ class PyLinter( child_linter.start() children.append(child_linter) - for files_or_module in expanded_files: - path = files_or_module["path"] - tasks_queue.put([path]) + for module_desc in expanded_files: + tasks_queue.put([module_desc.path]) # collect results from child linters failed = False @@ -1047,9 +1046,12 @@ class PyLinter( if interfaces.implements(checker, interfaces.IAstroidChecker): walker.add_checker(checker) # build ast and check modules or packages - for descr in self.expand_files(files_or_modules): - modname, filepath, is_arg = descr["name"], descr["path"], descr["isarg"] - if not self.should_analyze_file(modname, filepath, is_argument=is_arg): + for module_desc in self.expand_files(files_or_modules): + modname = module_desc.name + filepath = module_desc.path + if not module_desc.isarg and not self.should_analyze_file( + modname, filepath + ): continue self.set_current_module(modname, filepath) @@ -1060,7 +1062,7 @@ class PyLinter( # XXX to be correct we need to keep module_msgs_state for every # analyzed module (the problem stands with localized messages which # are only detected in the .close step) - self.file_state = utils.FileState(descr["basename"]) + self.file_state = utils.FileState(module_desc.basename) self._ignore_file = False # fix the current file (if the source file was not available or # if it's actually a c extension) diff --git a/pylint/utils.py b/pylint/utils.py index 921930d21..a70c4bb53 100644 --- a/pylint/utils.py +++ b/pylint/utils.py @@ -1147,6 +1147,11 @@ def _modpath_from_file(filename, is_namespace): ) +ModuleDescription = collections.namedtuple( + "ModuleDescription", ["path", "name", "basepath", "basename", "isarg"] +) + + def expand_modules(files_or_modules, black_list, black_list_re): """take a list of files/modules/packages and return the list of tuple (file, module name) which have to be actually checked @@ -1195,15 +1200,10 @@ def expand_modules(files_or_modules, black_list, black_list_re): is_directory = modutils.is_directory(spec) if not is_namespace: - result.append( - { - "path": filepath, - "name": modname, - "isarg": True, - "basepath": filepath, - "basename": modname, - } + mod_desc = ModuleDescription( + filepath, modname, filepath, modname, isarg=True ) + result.append(mod_desc) has_init = ( not (modname.endswith(".__init__") or modname == "__init__") @@ -1221,15 +1221,10 @@ def expand_modules(files_or_modules, black_list, black_list_re): modpath = _modpath_from_file(subfilepath, is_namespace) submodname = ".".join(modpath) - result.append( - { - "path": subfilepath, - "name": submodname, - "isarg": False, - "basepath": filepath, - "basename": modname, - } + mod_desc = ModuleDescription( + subfilepath, submodname, filepath, modname, isarg=False ) + result.append(mod_desc) return result, errors |