django-stubs icon indicating copy to clipboard operation
django-stubs copied to clipboard

Django 6.0: Add stubs for built-in CSP support

Open federicobond opened this issue 1 month ago • 5 comments

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.

federicobond avatar Dec 04 '25 09:12 federicobond

Apparently the stubtest job needs the Django 6.0 dependency update to be merged first.

federicobond avatar Dec 04 '25 11:12 federicobond

Django 6.0 dependency update to be merged first

  • ✅ merged https://github.com/typeddjango/django-stubs/pull/2939

intgr avatar Dec 10 '25 12:12 intgr

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.

intgr avatar Dec 10 '25 12:12 intgr

Should I include undocumented functions like get_nonce and build_policy in the type stubs or allow them in the allowlist?

federicobond avatar Dec 11 '25 02:12 federicobond

Yes, add them to stubs. If you know they are undocumented, it's worth adding a code comment about it.

intgr avatar Dec 11 '25 06:12 intgr

I've updated the PR based on the review comments. All build jobs pass now.

federicobond avatar Dec 12 '25 02:12 federicobond