From 613bcc2008846c6c15e716f7d1ddecfb3fe63ee0 Mon Sep 17 00:00:00 2001 From: Jeremy Satterfield Date: Wed, 29 Nov 2023 15:23:11 -0600 Subject: [PATCH] use django aliases for ranges to support psycopg 2 and 3 --- pylint_django/transforms/fields.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pylint_django/transforms/fields.py b/pylint_django/transforms/fields.py index 70b96f12..f46e4131 100644 --- a/pylint_django/transforms/fields.py +++ b/pylint_django/transforms/fields.py @@ -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])