# HG changeset patch
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1364572672 -3600
# Fri Mar 29 16:57:52 2013 +0100
# Node ID 76de04726839363a9725c27708a17e3a57c3380b
# Parent 9fad9b347afa67d32407603c52c30add992d24e7
stop relying on is_standard_module to avoid having internal dependencies in external deps report. Closes #124660
# User Sylvain Thénault <sylvain.thenault@logilab.fr>
# Date 1364572672 -3600
# Fri Mar 29 16:57:52 2013 +0100
# Node ID 76de04726839363a9725c27708a17e3a57c3380b
# Parent 9fad9b347afa67d32407603c52c30add992d24e7
stop relying on is_standard_module to avoid having internal dependencies in external deps report. Closes #124660
@@ -1,9 +1,14 @@
1 ChangeLog for PyLint 2 ==================== 3 4 -- 5 + * #124660: internal dependencies should not appear in external dependencies 6 + report 7 + 8 + 9 +2013-02-26 -- 0.27.0 10 11 * #20693: replace pylint.el by Ian Eure version (patch by J.Kotta) 12 13 * #105327: add support for --disable=all option and deprecate the 14 'disable-all' inline directive in favour of 'skip-file' (patch by
@@ -50,25 +50,10 @@
15 if found and not are_exclusive(first, node): 16 return first 17 18 # utilities to represents import dependencies as tree and dot graph ########### 19 20 -def filter_dependencies_info(dep_info, package_dir, mode='external'): 21 - """filter external or internal dependencies from dep_info (return a 22 - new dictionary containing the filtered modules only) 23 - """ 24 - if mode == 'external': 25 - filter_func = lambda x: not is_standard_module(x, (package_dir,)) 26 - else: 27 - assert mode == 'internal' 28 - filter_func = lambda x: is_standard_module(x, (package_dir,)) 29 - result = {} 30 - for importee, importers in dep_info.iteritems(): 31 - if filter_func(importee): 32 - result[importee] = importers 33 - return result 34 - 35 def make_tree_defs(mod_files_list): 36 """get a list of 2-uple (module, list_of_files_which_import_this_module), 37 it will return a dictionary to represent this as a tree 38 """ 39 tree_defs = {}
@@ -311,11 +296,11 @@
40 # handle dependencies 41 importedmodnames = self.stats['dependencies'].setdefault( 42 importedmodname, set()) 43 if not context_name in importedmodnames: 44 importedmodnames.add(context_name) 45 - if is_standard_module( importedmodname, (self.package_dir(),) ): 46 + if is_standard_module(importedmodname, (self.package_dir(),)): 47 # update import graph 48 mgraph = self.import_graph.setdefault(context_name, set()) 49 if not importedmodname in mgraph: 50 mgraph.add(importedmodname) 51
@@ -371,21 +356,27 @@
52 def _external_dependencies_info(self): 53 """return cached external dependencies information or build and 54 cache them 55 """ 56 if self.__ext_dep_info is None: 57 - self.__ext_dep_info = filter_dependencies_info( 58 - self.stats['dependencies'], self.package_dir(), 'external') 59 + package = self.linter.base_name 60 + self.__ext_dep_info = result = {} 61 + for importee, importers in self.stats['dependencies'].iteritems(): 62 + if not importee.startswith(package): 63 + result[importee] = importers 64 return self.__ext_dep_info 65 66 def _internal_dependencies_info(self): 67 """return cached internal dependencies information or build and 68 cache them 69 """ 70 if self.__int_dep_info is None: 71 - self.__int_dep_info = filter_dependencies_info( 72 - self.stats['dependencies'], self.package_dir(), 'internal') 73 + package = self.linter.base_name 74 + self.__int_dep_info = result = {} 75 + for importee, importers in self.stats['dependencies'].iteritems(): 76 + if importee.startswith(package): 77 + result[importee] = importers 78 return self.__int_dep_info 79 80 81 def register(linter): 82 """required method to auto register this checker """