pylint/checkers/imports.py
def _add_imported_module(self, node, importedmodname):
        """notify an imported module, used to analyze dependencies"""
        module_file = node.root().file
        context_name = node.root().name
        base = os.path.splitext(os.path.basename(module_file))[0]

        try:
            importedmodname = astroid.modutils.get_module_part(
                importedmodname, module_file
            )
        except ImportError:
            pass

        if context_name == importedmodname:
            self.add_message("import-self", node=node)

        elif not astroid.modutils.is_standard_module(importedmodname):
            # if this is not a package __init__ module
            if base != "__init__" and context_name not in self._module_pkg:
                # record the module's parent, or the module itself if this is
                # a top level module, as the package it belongs to
                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]

            # handle dependencies
            importedmodnames = self.stats["dependencies"].setdefault(
                importedmodname, set()
            )
            if context_name not in importedmodnames:
                importedmodnames.add(context_name)

            # update import graph
            self.import_graph[context_name].add(importedmodname)
            if not self.linter.is_message_enabled("cyclic-import", line=node.lineno):
                self._excluded_edges[context_name].add(importedmodname)
def _add_imported_module(self, node, importedmodname):
        module_file = node.root().file
        context_name = node.root().name
        base = os.path.splitext(os.path.basename(module_file))[0]

        try:
            importedmodname = astroid.modutils.get_module_part(
                importedmodname, module_file
            )
        except ImportError:
            pass

        if context_name == importedmodname:
            self.add_message("import-self", node=node)

        elif not astroid.modutils.is_standard_module(importedmodname):
            # if this is not a package __init__ module
            if base != "__init__" and context_name not in self._module_pkg:
                # record the module's parent, or the module itself if this is
                # a top level module, as the package it belongs to
                self._module_pkg[context_name] = context_name.rsplit(".", 1)[0]

            # handle dependencies
            importedmodnames = self.stats["dependencies"].setdefault(
                importedmodname, set()
            )
            if context_name not in importedmodnames:
                importedmodnames.add(context_name)

            # update import graph
            self.import_graph[context_name].add(importedmodname)
            if not self.linter.is_message_enabled("cyclic-import", line=node.lineno):
                self._excluded_edges[context_name].add(importedmodname)
def _add_imported_module ( self , node , importedmodname ) : module_file = node . root ( ) . file context_name = node . root ( ) . name base = os . path . splitext ( os . path . basename ( module_file ) ) [ 0 ] try : importedmodname = astroid . modutils . get_module_part ( importedmodname , module_file ) except ImportError : pass if context_name == importedmodname : self . add_message ( "import-self" , node = node ) elif not astroid . modutils . is_standard_module ( importedmodname ) : # if this is not a package __init__ module if base != "__init__" and context_name not in self . _module_pkg : # record the module's parent, or the module itself if this is # a top level module, as the package it belongs to self . _module_pkg [ context_name ] = context_name . rsplit ( "." , 1 ) [ 0 ] # handle dependencies importedmodnames = self . stats [ "dependencies" ] . setdefault ( importedmodname , set ( ) ) if context_name not in importedmodnames : importedmodnames . add ( context_name ) # update import graph self . import_graph [ context_name ] . add ( importedmodname ) if not self . linter . is_message_enabled ( "cyclic-import" , line = node . lineno ) : self . _excluded_edges [ context_name ] . add ( importedmodname )
notify an imported module, used to analyze dependencies
notify an imported module used to analyze dependencies