Fix include_bundles in extension static bundles and add type safety.

Review Request #13652 — Created March 20, 2024 and submitted

Information

Djblets
release-5.x

Reviewers

Several years ago, during a Django upgrade, we updated the extension
static media template tag code to correctly join strings together for
loading bundles, using format_html_join instead of naively joining
strings. This was commit 080996bf0.

Part of this involved yielding tuples in a generator, but we missed some
yields. When using include_bundles, we ended up yielding strings and
not tuples of strings, and this broke the process by which they were
joined.

This fixes that issue, and adds type safety throughout the template tag
code.

Unit tests have also been updated to cover include_bundles, so it
doesn't regress.

Unit tests and type checkers pass.

Summary ID
Fix include_bundles in extension static bundles and add type safety.
Several years ago, during a Django upgrade, we updated the extension static media template tag code to correctly join strings together for loading bundles, using `format_html_join` instead of naively joining strings. This was commit 080996bf0. Part of this involved yielding tuples in a generator, but we missed some yields. When using `include_bundles`, we ended up yielding strings and not tuples of strings, and this broke the process by which they were joined. This fixes that issue, and adds type safety throughout the template tag code. Unit tests have also been updated to cover `include_bundles`, so it doesn't regress.
46bbf38debcbb809f46cf576ec09ddd3682078bb
Description From Last Updated

We should start getting Iterator from collections.abc instead.

daviddavid
david
  1. 
      
  2. Show all issues

    We should start getting Iterator from collections.abc instead.

    1. Not until we move exclusively to 3.9+. collections.abc.Iterator[...] isn't valid in 3.8.

    2. It should be, at least as a type hint, assuming we have from __future__ import annotations.

  3. 
      
chipx86
Review request changed

Status: Closed (submitted)

Change Summary:

Pushed to release-5.x (a0666d6)
Loading...