pylint/extensions/_check_docs_utils.py
def possible_exc_types(node):
    """
    Gets all of the possible raised exception types for the given raise node.

    .. note::

        Caught exception types are ignored.


    :param node: The raise node to find exception types for.
    :type node: astroid.node_classes.NodeNG

    :returns: A list of exception types possibly raised by :param:`node`.
    :rtype: set(str)
    """
    excs = []
    if isinstance(node.exc, astroid.Name):
        inferred = utils.safe_infer(node.exc)
        if inferred:
            excs = [inferred.name]
    elif node.exc is None:
        handler = node.parent
        while handler and not isinstance(handler, astroid.ExceptHandler):
            handler = handler.parent

        if handler and handler.type:
            inferred_excs = astroid.unpack_infer(handler.type)
            excs = (exc.name for exc in inferred_excs if exc is not astroid.Uninferable)
    else:
        target = _get_raise_target(node)
        if isinstance(target, astroid.ClassDef):
            excs = [target.name]
        elif isinstance(target, astroid.FunctionDef):
            for ret in target.nodes_of_class(astroid.Return):
                if ret.frame() != target:
                    # return from inner function - ignore it
                    continue

                val = utils.safe_infer(ret.value)
                if (
                    val
                    and isinstance(val, (astroid.Instance, astroid.ClassDef))
                    and utils.inherit_from_std_ex(val)
                ):
                    excs.append(val.name)

    try:
        return {exc for exc in excs if not utils.node_ignores_exception(node, exc)}
    except astroid.InferenceError:
        return set()
def possible_exc_types(node):
    excs = []
    if isinstance(node.exc, astroid.Name):
        inferred = utils.safe_infer(node.exc)
        if inferred:
            excs = [inferred.name]
    elif node.exc is None:
        handler = node.parent
        while handler and not isinstance(handler, astroid.ExceptHandler):
            handler = handler.parent

        if handler and handler.type:
            inferred_excs = astroid.unpack_infer(handler.type)
            excs = (exc.name for exc in inferred_excs if exc is not astroid.Uninferable)
    else:
        target = _get_raise_target(node)
        if isinstance(target, astroid.ClassDef):
            excs = [target.name]
        elif isinstance(target, astroid.FunctionDef):
            for ret in target.nodes_of_class(astroid.Return):
                if ret.frame() != target:
                    # return from inner function - ignore it
                    continue

                val = utils.safe_infer(ret.value)
                if (
                    val
                    and isinstance(val, (astroid.Instance, astroid.ClassDef))
                    and utils.inherit_from_std_ex(val)
                ):
                    excs.append(val.name)

    try:
        return {exc for exc in excs if not utils.node_ignores_exception(node, exc)}
    except astroid.InferenceError:
        return set()
def possible_exc_types ( node ) : excs = [ ] if isinstance ( node . exc , astroid . Name ) : inferred = utils . safe_infer ( node . exc ) if inferred : excs = [ inferred . name ] elif node . exc is None : handler = node . parent while handler and not isinstance ( handler , astroid . ExceptHandler ) : handler = handler . parent if handler and handler . type : inferred_excs = astroid . unpack_infer ( handler . type ) excs = ( exc . name for exc in inferred_excs if exc is not astroid . Uninferable ) else : target = _get_raise_target ( node ) if isinstance ( target , astroid . ClassDef ) : excs = [ target . name ] elif isinstance ( target , astroid . FunctionDef ) : for ret in target . nodes_of_class ( astroid . Return ) : if ret . frame ( ) != target : # return from inner function - ignore it continue val = utils . safe_infer ( ret . value ) if ( val and isinstance ( val , ( astroid . Instance , astroid . ClassDef ) ) and utils . inherit_from_std_ex ( val ) ) : excs . append ( val . name ) try : return { exc for exc in excs if not utils . node_ignores_exception ( node , exc ) } except astroid . InferenceError : return set ( )
Gets all of the possible raised exception types for the given raise node.

    .. note::

        Caught exception types are ignored.


    :param node: The raise node to find exception types for.
    :type node: astroid.node_classes.NodeNG

    :returns: A list of exception types possibly raised by :param:`node`.
    :rtype: set(str)
Gets all of the possible raised exception types for the given raise node .