Django 6.0: Add stubs for built-in CSP support
Documentation: https://docs.djangoproject.com/en/6.0/ref/csp/
I reused a trick from django-stubs/db/models/enums.pyi to make it compatible with Python < 3.11.
Apparently the stubtest job needs the Django 6.0 dependency update to be merged first.
Django 6.0 dependency update to be merged first
- ✅ merged https://github.com/typeddjango/django-stubs/pull/2939
Please look at stubtest output https://github.com/typeddjango/django-stubs/actions/runs/20098667950/job/57663468906?pr=2931
And update stubs or stubtest allowlist files scripts/stubtest/allowlist_*.txt as needed.
Should I include undocumented functions like get_nonce and build_policy in the type stubs or allow them in the allowlist?
Yes, add them to stubs. If you know they are undocumented, it's worth adding a code comment about it.
I've updated the PR based on the review comments. All build jobs pass now.