pylint/checkers/design_analysis.py
def _is_dataclass(node: astroid.ClassDef) -> bool:
    """Check if a class definition defines a Python 3.7+ dataclass

    :param node: The class node to check.
    :type node: astroid.ClassDef

    :returns: True if the given node represents a dataclass class. False otherwise.
    :rtype: bool
    """
    if not node.decorators:
        return False

    root_locals = node.root().locals
    for decorator in node.decorators.nodes:
        if isinstance(decorator, astroid.Call):
            decorator = decorator.func
        if not isinstance(decorator, (astroid.Name, astroid.Attribute)):
            continue
        if isinstance(decorator, astroid.Name):
            name = decorator.name
        else:
            name = decorator.attrname
        if name == DATACLASS_DECORATOR and DATACLASS_DECORATOR in root_locals:
            return True
    return False
def _is_dataclass(node: astroid.ClassDef) -> bool:
    if not node.decorators:
        return False

    root_locals = node.root().locals
    for decorator in node.decorators.nodes:
        if isinstance(decorator, astroid.Call):
            decorator = decorator.func
        if not isinstance(decorator, (astroid.Name, astroid.Attribute)):
            continue
        if isinstance(decorator, astroid.Name):
            name = decorator.name
        else:
            name = decorator.attrname
        if name == DATACLASS_DECORATOR and DATACLASS_DECORATOR in root_locals:
            return True
    return False
def _is_dataclass ( node : astroid . ClassDef ) -> bool : if not node . decorators : return False root_locals = node . root ( ) . locals for decorator in node . decorators . nodes : if isinstance ( decorator , astroid . Call ) : decorator = decorator . func if not isinstance ( decorator , ( astroid . Name , astroid . Attribute ) ) : continue if isinstance ( decorator , astroid . Name ) : name = decorator . name else : name = decorator . attrname if name == DATACLASS_DECORATOR and DATACLASS_DECORATOR in root_locals : return True return False
Check if a class definition defines a Python 3.7+ dataclass

    :param node: The class node to check.
    :type node: astroid.ClassDef

    :returns: True if the given node represents a dataclass class. False otherwise.
    :rtype: bool
Check if a class definition defines a Python 3 . 7 + dataclass