pylint/checkers/utils.py
def is_from_fallback_block(node: astroid.node_classes.NodeNG) -> bool:
    """Check if the given node is from a fallback import block."""
    context = find_try_except_wrapper_node(node)
    if not context:
        return False

    if isinstance(context, astroid.ExceptHandler):
        other_body = context.parent.body
        handlers = context.parent.handlers
    else:
        other_body = itertools.chain.from_iterable(
            handler.body for handler in context.handlers
        )
        handlers = context.handlers

    has_fallback_imports = any(
        isinstance(import_node, (astroid.ImportFrom, astroid.Import))
        for import_node in other_body
    )
    ignores_import_error = _except_handlers_ignores_exception(handlers, ImportError)
    return ignores_import_error or has_fallback_imports
def is_from_fallback_block(node: astroid.node_classes.NodeNG) -> bool:
    context = find_try_except_wrapper_node(node)
    if not context:
        return False

    if isinstance(context, astroid.ExceptHandler):
        other_body = context.parent.body
        handlers = context.parent.handlers
    else:
        other_body = itertools.chain.from_iterable(
            handler.body for handler in context.handlers
        )
        handlers = context.handlers

    has_fallback_imports = any(
        isinstance(import_node, (astroid.ImportFrom, astroid.Import))
        for import_node in other_body
    )
    ignores_import_error = _except_handlers_ignores_exception(handlers, ImportError)
    return ignores_import_error or has_fallback_imports
def is_from_fallback_block ( node : astroid . node_classes . NodeNG ) -> bool : context = find_try_except_wrapper_node ( node ) if not context : return False if isinstance ( context , astroid . ExceptHandler ) : other_body = context . parent . body handlers = context . parent . handlers else : other_body = itertools . chain . from_iterable ( handler . body for handler in context . handlers ) handlers = context . handlers has_fallback_imports = any ( isinstance ( import_node , ( astroid . ImportFrom , astroid . Import ) ) for import_node in other_body ) ignores_import_error = _except_handlers_ignores_exception ( handlers , ImportError ) return ignores_import_error or has_fallback_imports
Check if the given node is from a fallback import block.
Check if the given node is from a fallback import block .