Skip to content

Commit c0408d7

Browse files
author
carlio
committed
[refs #201] Adding compat layer back in, and fixing compatability between astroid 2.04 and 2.1wq
1 parent 2ef6132 commit c0408d7

File tree

2 files changed

+41
-2
lines changed

2 files changed

+41
-2
lines changed

pylint_django/compat.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
try:
2+
from astroid.nodes import ClassDef, FunctionDef, ImportFrom, AssignName, Attribute
3+
except ImportError:
4+
from astroid.nodes import (
5+
Class as ClassDef,
6+
Function as FunctionDef,
7+
From as ImportFrom,
8+
AssName as AssignName,
9+
Getattr as Attribute,
10+
)
11+
12+
try:
13+
from astroid.bases import YES as Uninferable
14+
except ImportError:
15+
try:
16+
from astroid.util import YES as Uninferable
17+
except ImportError:
18+
from astroid.util import Uninferable
19+
20+
try:
21+
django = __import__("django")
22+
django_version = django.VERSION
23+
except ImportError:
24+
# if not available, will be handled by the django_installed checker
25+
django_version = (1, 5)
26+
27+
28+
def inferred(node):
29+
if hasattr(node, "inferred"):
30+
return node.inferred
31+
else:
32+
return node.infered
33+
34+
35+
def instantiate_class(node):
36+
if hasattr(node, "instantiate_class"):
37+
return node.instantiate_class
38+
else:
39+
return node.instanciate_class

pylint_django/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"""Utils."""
22
import sys
33

4-
from astroid.util import YES
4+
from pylint_django.compat import Uninferable
55
from astroid.bases import Instance
66
from astroid.nodes import ClassDef
77
from astroid.exceptions import InferenceError
@@ -15,7 +15,7 @@ def node_is_subclass(cls, *subclass_names):
1515
if not isinstance(cls, (ClassDef, Instance)):
1616
return False
1717

18-
if cls.bases == YES:
18+
if cls.bases == Uninferable:
1919
return False
2020
for base_cls in cls.bases:
2121
try:

0 commit comments

Comments
 (0)