Turn SCons.Variables.Variable
into a dataclass
#4658
+40
−42
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This moves the initialization into the
Variable
class itself, rather than being done in the_do_add
method of theVariables
class. We get nice printing and comparison for free via the dataclass mechanism, so the old methods are dropped fromVariable
.Also correct one long-standing minor inconsistency: if a list of names for a variable is given, it is split into name and aliases, with the name not duplicated into the aliases. If only one name is given (no aliases), it was also added as the sole entry in the aliases; now it is not added to the aliases. All the SCons usages of aliases combine them back together anyway, like:
So there's no need for the behavior of the one-name form, including the name in aliases. One test did need to change for this - the test of a custom help formatter function was wired to accept the old form, but only because of the way the custom formatter in the test was written, so this is a self-contained problem.
Contributor Checklist:
CHANGES.txt
andRELEASE.txt
(and read theREADME.rst
).