Skip to content

Commit 613bcc2

Browse files
jsattcarlio
authored andcommitted
use django aliases for ranges to support psycopg 2 and 3
1 parent 1bd739a commit 613bcc2

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

pylint_django/transforms/fields.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,10 @@ def apply_type_shim(cls, _context=None): # pylint: disable=too-many-statements
9191
elif cls.name in ("HStoreField", "JSONField"):
9292
base_nodes = scoped_nodes.builtin_lookup("dict")
9393
elif cls.name in _RANGE_FIELDS:
94-
base_nodes = MANAGER.ast_from_module_name("psycopg2._range").lookup("Range")
94+
try:
95+
base_nodes = MANAGER.ast_from_module_name("django.db.backends.postgresql.psycopg_any").lookup("Range")
96+
except AstroidImportError:
97+
base_nodes = MANAGER.ast_from_module_name("psycopg2._range").lookup("Range")
9598
else:
9699
return iter([cls])
97100

0 commit comments

Comments
 (0)