Skip to content

Commit d57a755

Browse files
fadedDexofanatodorov
authored andcommitted
Fixed AstroidImportError
1 parent 92f3975 commit d57a755

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

pylint_django/transforms/fields.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
import sys
2-
3-
from astroid import MANAGER, scoped_nodes, nodes, inference_tip
1+
from astroid import (
2+
MANAGER, scoped_nodes, nodes, inference_tip,
3+
AstroidImportError
4+
)
45

56
from pylint_django import utils
67

@@ -39,11 +40,10 @@ def apply_type_shim(cls, _context=None): # noqa
3940
elif cls.name == 'FloatField':
4041
base_nodes = scoped_nodes.builtin_lookup('float')
4142
elif cls.name == 'DecimalField':
42-
if sys.version_info >= (3, 5):
43-
# I dunno, I'm tired and this works :(
43+
try:
4444
base_nodes = MANAGER.ast_from_module_name('_decimal').lookup('Decimal')
45-
else:
46-
base_nodes = MANAGER.ast_from_module_name('decimal').lookup('Decimal')
45+
except AstroidImportError:
46+
base_nodes = MANAGER.ast_from_module_name('_pydecimal').lookup('Decimal')
4747
elif cls.name in ('SplitDateTimeField', 'DateTimeField'):
4848
base_nodes = MANAGER.ast_from_module_name('datetime').lookup('datetime')
4949
elif cls.name == 'TimeField':

0 commit comments

Comments
 (0)