Skip to content

fix pyright type errors for Django version compatibility#181

Merged
bckohan merged 1 commit intodjango-commons:mainfrom
bckohan-bot:fix/pyright-type-errors
Mar 17, 2026
Merged

fix pyright type errors for Django version compatibility#181
bckohan merged 1 commit intodjango-commons:mainfrom
bckohan-bot:fix/pyright-type-errors

Conversation

@bckohan-bot
Copy link
Contributor

Summary

  • Use getattr(model_enums, "ChoicesMeta") instead of direct attribute access to avoid a pyright error on Django 5.0+ stubs where ChoicesMeta no longer exists
  • Add # type: ignore[call-arg] on CheckConstraint(check=...) backward-compatibility branches (Django < 5.1), since current Django stubs only expose the condition= parameter
  • Add # type: ignore[attr-defined] on connection.operators access in query.py, which is a real runtime attribute but absent from Django's BaseDatabaseWrapper stubs

Test plan

  • Run just check-types-pyright and confirm 0 errors, 0 warnings, 0 informations
  • Run existing test suite to confirm no regressions

🤖 Generated with Claude Code

- Use getattr() for ChoicesMeta to avoid static attr access on Django 5.0+ stubs
- Suppress call-arg errors on CheckConstraint(check=...) backward-compat branches (Django < 5.1)
- Suppress attr-defined error on connection.operators which is untyped in Django stubs

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@bckohan-bot bckohan-bot requested a review from bckohan as a code owner March 17, 2026 05:35
@codecov
Copy link

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
src/django_enum/choices.py 100.00% <ø> (ø)
src/django_enum/fields.py 100.00% <ø> (ø)
src/django_enum/query.py 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@bckohan bckohan merged commit 5639987 into django-commons:main Mar 17, 2026
43 checks passed
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.

2 participants