Allow datagrid Column subclasses to set attributes on the class level.

Review Request #14824 — Created Feb. 17, 2026 and updated — Latest diff uploaded

Information

Djblets
release-5.x

Reviewers

Historically, Column subclasses had to override __init__ and set
attributes there. This was a bit messy and error-prone, as it was common
to mix up positional and keyword arguments when subclassing, and made
for harder customization for more complex class hierarchies.

Now, subclasses can set these arguments directly on the class as
attributes. The base Column class has defaults for all these fields,
which can be overridden by subclasses and further overridden when
calling __init__(). Built-in subclasses also provide their own fitting
this pattern.

To make this work, the arguments in __init__() are all set to UNSET
by default. If UNSET, class attributes (or more complex default
calculations) are used, but if any value is explicitly provided, it will
be used instead.

To help avoid the mess of positional and keyword arguments in these
classes, all arguments other than label are now keyword-only, with
positional arguments deprecated and scheduled for removal in Djblets 7.

This is now the recommended approach for column subclasses. It has the
benefit of storing less state per-instance, as well, as we only set the
values on the instance if they're explicitly provided during
construction.

Unit tests pass.

Tested updating existing columns to use this, and verified the new
settings were correct.

Commits

Files