Skip to content

Adapt type annotations to django-stubs 6.1.2 (unblocks lock file maintenance) - #343

Open
NumericalAdvantage wants to merge 1 commit into
mainfrom
fix/type-annotations-django-stubs-6-1-2
Open

NumericalAdvantage wants to merge 1 commit into
mainfrom
fix/type-annotations-django-stubs-6-1-2

Conversation

@NumericalAdvantage

Copy link
Copy Markdown
Contributor

Unblocks #305 (Renovate's lock file maintenance), whose CI has been failing the pyright step for three weeks, so its automerge never fired.

Type Type-annotation fix, no behaviour change
Surface radis/collections/views.py, radis/reports/api/serializers.py
Risk None at runtime; annotations and an equivalent DRF call
Checks pyright 0 errors with the current stubs (django-stubs 6.1.0 / pyright 1.1.411) and with the ones #305 brings (django-stubs 6.1.2 / pyright 1.1.414); collections and reports suites green
  • form_valid in the collection create/update views takes ModelForm[Collection] instead of a bare BaseModelForm; django-stubs 6.1.2 gives CreateView/UpdateView a default form type (ModelForm[_M]), and the bare annotation is no longer assignable to it
  • radis/collections/views.py gets from __future__ import annotations, because Django's ModelForm is not subscriptable at runtime (RADIS does not use the django-stubs-ext monkeypatch) and the annotation must not be evaluated
  • ReportSerializer reads the groups field's queryset through get_queryset() (which already returns a fresh .all()), instead of the queryset attribute; django-stubs 6.1.2 adds a descriptor __get__ to Manager, which makes pyright reject attribute reads typed QuerySet | Manager | None on DRF fields
How this was verified

Reproduced the four CI errors locally with the environment from the Renovate branch (uv sync --frozen on renovate/lock-file-maintenance), applied the two changes, and ran pyright over the whole project in both environments: 0 errors in each. The affected test suites pass; nothing changes at runtime.

Once this is on main, Renovate rebases #305 and the lock file maintenance should automerge as configured.

🤖 Generated with Claude Code

The lock file maintenance brings django-stubs 6.1.2 and pyright 1.1.414,
under which pyright rejects the bare BaseModelForm parameter of the
collection views' form_valid (the model-form views now default their form
type to ModelForm[_M]) and the reads of the DRF groups field's queryset
attribute (Manager gained a descriptor __get__). Annotate the forms as
ModelForm[Collection], kept out of runtime evaluation, and read the
queryset through get_queryset(). No behaviour change.
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 7 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 3e4e083f-f07b-4b2a-83d7-37aa5ff20832
📥 Commits

Reviewing files that changed from the base of the PR and between 766b52b and 70a7045.

📒 Files selected for processing (2)
  • radis/collections/views.py
  • radis/reports/api/serializers.py
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

This branch has not been deployed

No deployments
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.

1 participant