Remove LicenseInfo.private_data and help extensibility.
Review Request #14496 — Created June 29, 2025 and updated
Originally when the new licensing code was added, the intent was to back
license representations by aLicenseInfo
and to allow license
providers to extend that by plugging state into aprivate_data
member.Since the original design, support for
LicenseInfo
subclasses was
added, largely removing the need forprivate_data
. In practice,
though, theLicenseInfo
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.
Summary | ID |
---|---|
9982f25aa7714bd7119795589848679e127073e2 |
Description | From | Last Updated |
---|---|---|
I thought we can't use this on Python 3.8 or 3.9? |
|
- Change Summary:
-
Changed
LicenseInfo
to be a standard class. - Description:
-
Originally when the new licensing code was added, the intent was to back
license representations by a LicenseInfo
and to allow licenseproviders to extend that by plugging state into a private_data
member.Since the original design, support for
LicenseInfo
subclasses wasadded, largely removing the need for private_data
. In practice,though, the LicenseInfo
dataclass could not be extended with newrequired 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 removeprivate_data
.~ 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. ~ Going forward, we should ensure that all dataclasses use
kw_only=True
~ to help with forward-compatibility and extensibility. ~ 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. - Commits:
-
Summary ID d32f241fc16c3c8db291f6786813f703474c57f4 9982f25aa7714bd7119795589848679e127073e2 - Diff:
-
Revision 2 (+236 -66)