Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use django aliases for ranges to support psycopg 2 and 3 #421

Merged
merged 1 commit into from
Jul 20, 2024

Conversation

jsatt
Copy link
Contributor

@jsatt jsatt commented Nov 29, 2023

Django 4.2 introduces support for psycopg 3, but when using psycopg 3 Ranges without psycopg2 install, pyling-django raises an AstroidImportError due to apply_type_shim checking for psycopg2._range. Django 4.2 also now provides aliases to the Ranges in the appropriate library. This change uses these aliases for checking and falls back using psycopg2 if they are not available (running Django <4.2).

@michael-k
Copy link
Contributor

I tried your branch, but now I run into a different problem. The field is defined as period = DateRangeField(null=False, blank=False) and we use period.lower/period.upper. With psycopg3, pylint complains that Instance of 'DateRangeField' has no 'lower' member (no-member) (same for uppper).

Can you please include psycop3 variants of external_psycopg2_noerror_postgres_fields.py and external_psycopg2_noerror_postgres_fields.rc in this PR?


I've also tried period[0]/period[1] with psycopg3 and pylint complains that Value 'self.period' is unsubscriptable (unsubscriptable-object).

  • Django: 4.2.10 and 5.0.2
  • psycopg: 3.1.18

carlio added a commit that referenced this pull request Jul 20, 2024
@carlio carlio merged commit 613bcc2 into pylint-dev:master Jul 20, 2024
1 check passed
@carlio
Copy link
Collaborator

carlio commented Jul 20, 2024

I have added the tests suggested and merged this in, to find out if they work ; if not I will fix things up. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants