Skip to content

Commit

Permalink
Core: Expose option aliases (ArchipelagoMW#3512)
Browse files Browse the repository at this point in the history
  • Loading branch information
hatkirby authored Jun 15, 2024
1 parent c61505b commit e796f0a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Options.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,8 @@ def __new__(mcs, name, bases, attrs):
attrs["name_lookup"].update({option_id: name for name, option_id in new_options.items()})
options.update(new_options)
# apply aliases, without name_lookup
aliases = {name[6:].lower(): option_id for name, option_id in attrs.items() if
name.startswith("alias_")}
aliases = attrs["aliases"] = {name[6:].lower(): option_id for name, option_id in attrs.items() if
name.startswith("alias_")}

assert (
name in {"Option", "VerifyKeys"} or # base abstract classes don't need default
Expand Down Expand Up @@ -147,6 +147,7 @@ class Option(typing.Generic[T], metaclass=AssembleOptions):
name_lookup: typing.ClassVar[typing.Dict[T, str]] # type: ignore
# https://github.com/python/typing/discussions/1460 the reason for this type: ignore
options: typing.ClassVar[typing.Dict[str, int]]
aliases: typing.ClassVar[typing.Dict[str, int]]

def __repr__(self) -> str:
return f"{self.__class__.__name__}({self.current_option_name})"
Expand Down

0 comments on commit e796f0a

Please sign in to comment.