Skip to content

Commit

Permalink
use django aliases for ranges to support psycopg 2 and 3
Browse files Browse the repository at this point in the history
  • Loading branch information
jsatt authored and carlio committed Jul 20, 2024
1 parent 1bd739a commit 613bcc2
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion pylint_django/transforms/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,10 @@ def apply_type_shim(cls, _context=None): # pylint: disable=too-many-statements
elif cls.name in ("HStoreField", "JSONField"):
base_nodes = scoped_nodes.builtin_lookup("dict")
elif cls.name in _RANGE_FIELDS:
base_nodes = MANAGER.ast_from_module_name("psycopg2._range").lookup("Range")
try:
base_nodes = MANAGER.ast_from_module_name("django.db.backends.postgresql.psycopg_any").lookup("Range")
except AstroidImportError:
base_nodes = MANAGER.ast_from_module_name("psycopg2._range").lookup("Range")
else:
return iter([cls])

Expand Down

0 comments on commit 613bcc2

Please sign in to comment.