Core: inherit option aliases in subclasses#6272
Conversation
|
Personally, this is not a proper fix for the issue because this is a band-aid/hardcoded fix for only |
`AssembleOptions.__new__` rebuilt each class's `aliases` from only that class's own
`alias_*` attributes, while `options`/`name_lookup` were merged from the base classes.
Subclasses therefore silently dropped inherited aliases -- e.g. `ItemsAccessibility.aliases`
was `{}`, so the documented `none`/`locations` aliases were missing from the mapping.
Merge aliases from the base classes too, and drop any inherited alias whose name the subclass
redefines as a real option (so `ItemsAccessibility`'s `items` option wins over `Accessibility`'s
`items` alias). `options` is unchanged, so option resolution via `from_text` is unaffected.
Fixes ArchipelagoMW#5124.
184a23f to
ec03a88
Compare
|
Good call, thanks — reworked to fix the root cause (option 1 in #5124) instead of hardcoding the aliases on
|
|
Oh, this is all just AI slop isn't it? great |
What is this fixing or adding?
AssembleOptions.__new__rebuilt each option class'saliasesdict from only that class's ownalias_*attributes, even thoughoptionsandname_lookupare merged from the base classes. So any subclass of a concrete option silently dropped its inherited aliases — e.g.ItemsAccessibility.aliaseswas{}, so the documentednone/locationsaliases were missing from the alias mapping.This addresses the root cause (option 1 from #5124) instead of hardcoding the aliases on
ItemsAccessibility: aliases are now merged from the base classes as well, and any inherited alias whose name the subclass redefines as a real option is dropped (soItemsAccessibility'sitemsoption wins overAccessibility'sitemsalias).optionsis unchanged, so option resolution viafrom_textis unaffected — only the.aliasesmapping is corrected. This fixes every subclassed option, not justItemsAccessibility.Fixes #5124.
How was this tested?
Rewrote
test_subclassed_choice_inherits_aliasesintest/general/test_options.py:ItemsAccessibility.aliases == {"none": 2, "locations": 0}(the exact expected result from Bug: TheItemsAccessibilityoption has no aliases set #5124),Accessibility.aliasesis unchanged, andnone/locationsstill resolve viafrom_text.Choicesubclass hierarchy proves the mechanism is general: a plain subclass inherits all parent aliases, and a subclass that redefines an inherited alias name as a real option drops that alias (the option wins).pytest test/general/test_options.py test/webhost/test_option_presets.py→ all pass (12 tests / 14202 subtests), confirming no world's options regress now that aliases are inherited.