PHP 8.2.30
Preview: utils.py Size: 1.15 KB
/proc/thread-self/root/opt/cloudlinux/venv/lib/python3.11/site-packages/pylint_django/utils.py

"""Utils."""
import sys

import astroid
from astroid.bases import Instance
from astroid.exceptions import InferenceError
from astroid.nodes import ClassDef

from pylint_django.compat import Uninferable

PY3 = sys.version_info >= (3, 0)  # TODO: pylint_django doesn't support Py2 any more


def node_is_subclass(cls, *subclass_names):
    """Checks if cls node has parent with subclass_name."""
    if not isinstance(cls, (ClassDef, Instance)):
        return False

    if cls.bases == Uninferable:
        return False
    for base_cls in cls.bases:
        try:
            for inf in base_cls.inferred():
                if inf.qname() in subclass_names:
                    return True
                if inf != cls and node_is_subclass(inf, *subclass_names):
                    # check up the hierarchy in case we are a subclass of
                    # a subclass of a subclass ...
                    return True
        except InferenceError:
            continue

    return False


def is_migrations_module(node):
    if not isinstance(node, astroid.Module):
        return False

    return "migrations" in node.path[0] and not node.path[0].endswith("__init__.py")

Directory Contents

Dirs: 5 × Files: 5

Name Size Perms Modified Actions
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
checkers DIR
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
tests DIR
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
- drwxr-xr-x 2026-02-06 08:01:08
Edit Download
1.07 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.48 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
1.15 KB lrw-r--r-- 2026-01-20 13:01:48
Edit Download
393 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download
28 B lrw-r--r-- 2026-01-20 13:01:48
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).