Remove LicenseInfo.private_data and help extensibility.

Review Request #14496 — Created June 29, 2025 and updated — Latest diff uploaded

Information

Review Board
release-7.1.x

Reviewers

Originally when the new licensing code was added, the intent was to back
license representations by a LicenseInfo and to allow license
providers to extend that by plugging state into a private_data member.

Since the original design, support for LicenseInfo subclasses was
added, largely removing the need for private_data. In practice,
though, the LicenseInfo dataclass could not be extended with new
required arguments due to the way that the dataclass was registered.
By default, dataclasses register fields as positional arguments instead
of keyword-only arguments, and this means that any field registered
after the last field with a default must itself have a default, even in
subclasses. This isn't ideal for this purpose.

We can't use kw_only=True, since that's only available on Python 3.10
and higher, and there's no getting around the internal logic that
impacts subclasses. Plus, dataclasses are slow and truly necessary, just
a convenience.

So to help facilitate License Provider backends with custom state, and
avoid the dataclass issues, this has been converted to a standard class.
This will also make it easier for subclasses to override it in a
consistent way without having to tie into the dataclass-specific
post-construction hooks.

Unit tests pass.

Successfully created and used subclasses of LicenseInfo with new
required fields.

Diff Revision 1

This is not the most recent revision of the diff. The latest diff is revision 2. See what's changed.

orig
1
2

Commits

First Last Summary ID Author
Remove LicenseInfo.private_data and help extensibility.
Originally when the new licensing code was added, the intent was to back license representations by a `LicenseInfo` and to allow license providers to extend that by plugging state into a `private_data` member. Since the original design, support for `LicenseInfo` subclasses was added, largely removing the need for `private_data`. In practice, though, the `LicenseInfo` dataclass could not be extended with new required arguments due to the way that the dataclass was registered. By default, dataclasses register fields as positional arguments instead of keyword-only arguments, and this means that any field registered after the last field with a default must itself have a default, even in subclasses. This isn't ideal for this purpose. To help facilitate License Provider backends with custom state, we now register the dataclass with `kw_only=True`, and remove `private_data`. Going forward, we should ensure that all dataclasses use `kw_only=True` to help with forward-compatibility and extensibility.
d32f241fc16c3c8db291f6786813f703474c57f4 Christian Hammond
reviewboard/licensing/license.py
Loading...