Skip to content

Commit

Permalink
[refs #201] Adding compat layer back in, and fixing compatability bet…
Browse files Browse the repository at this point in the history
…ween astroid 2.04 and 2.1wq
  • Loading branch information
carlio committed Nov 26, 2018
1 parent 2ef6132 commit c0408d7
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 2 deletions.
39 changes: 39 additions & 0 deletions pylint_django/compat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
try:
from astroid.nodes import ClassDef, FunctionDef, ImportFrom, AssignName, Attribute
except ImportError:
from astroid.nodes import (
Class as ClassDef,
Function as FunctionDef,
From as ImportFrom,
AssName as AssignName,
Getattr as Attribute,
)

try:
from astroid.bases import YES as Uninferable
except ImportError:
try:
from astroid.util import YES as Uninferable
except ImportError:
from astroid.util import Uninferable

try:
django = __import__("django")
django_version = django.VERSION
except ImportError:
# if not available, will be handled by the django_installed checker
django_version = (1, 5)


def inferred(node):
if hasattr(node, "inferred"):
return node.inferred
else:
return node.infered


def instantiate_class(node):
if hasattr(node, "instantiate_class"):
return node.instantiate_class
else:
return node.instanciate_class
4 changes: 2 additions & 2 deletions pylint_django/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
"""Utils."""
import sys

from astroid.util import YES
from pylint_django.compat import Uninferable
from astroid.bases import Instance
from astroid.nodes import ClassDef
from astroid.exceptions import InferenceError
Expand All @@ -15,7 +15,7 @@ def node_is_subclass(cls, *subclass_names):
if not isinstance(cls, (ClassDef, Instance)):
return False

if cls.bases == YES:
if cls.bases == Uninferable:
return False
for base_cls in cls.bases:
try:
Expand Down

0 comments on commit c0408d7

Please sign in to comment.