pylint/checkers/imports.py
def _get_first_import(node, context, name, base, level, alias):
    """return the node where [base.]<name> is imported or None if not found
    """
    fullname = "%s.%s" % (base, name) if base else name

    first = None
    found = False
    for first in context.body:
        if first is node:
            continue
        if first.scope() is node.scope() and first.fromlineno > node.fromlineno:
            continue
        if isinstance(first, astroid.Import):
            if any(fullname == iname[0] for iname in first.names):
                found = True
                break
        elif isinstance(first, astroid.ImportFrom):
            if level == first.level:
                for imported_name, imported_alias in first.names:
                    if fullname == "%s.%s" % (first.modname, imported_name):
                        found = True
                        break
                    if (
                        name != "*"
                        and name == imported_name
                        and not (alias or imported_alias)
                    ):
                        found = True
                        break
                if found:
                    break
    if found and not astroid.are_exclusive(first, node):
        return first
    return None
def _get_first_import(node, context, name, base, level, alias):
    """return the node where [base.]<name> is imported or None if not found
    """
    fullname = "%s.%s" % (base, name) if base else name

    first = None
    found = False
    for first in context.body:
        if first is node:
            continue
        if first.scope() is node.scope() and first.fromlineno > node.fromlineno:
            continue
        if isinstance(first, astroid.Import):
            if any(fullname == iname[0] for iname in first.names):
                found = True
                break
        elif isinstance(first, astroid.ImportFrom):
            if level == first.level:
                for imported_name, imported_alias in first.names:
                    if fullname == "%s.%s" % (first.modname, imported_name):
                        found = True
                        break
                    if (
                        name != "*"
                        and name == imported_name
                        and not (alias or imported_alias)
                    ):
                        found = True
                        break
                if found:
                    break
    if found and not astroid.are_exclusive(first, node):
        return first
    return None
def _get_first_import ( node , context , name , base , level , alias ) : fullname = "%s.%s" % ( base , name ) if base else name first = None found = False for first in context . body : if first is node : continue if first . scope ( ) is node . scope ( ) and first . fromlineno > node . fromlineno : continue if isinstance ( first , astroid . Import ) : if any ( fullname == iname [ 0 ] for iname in first . names ) : found = True break elif isinstance ( first , astroid . ImportFrom ) : if level == first . level : for imported_name , imported_alias in first . names : if fullname == "%s.%s" % ( first . modname , imported_name ) : found = True break if ( name != "*" and name == imported_name and not ( alias or imported_alias ) ) : found = True break if found : break if found and not astroid . are_exclusive ( first , node ) : return first return None
return the node where [base.]<name> is imported or None if not found
return the node where [ base . ] <name > is imported or None if not found