From a899e925dfab566db85009c513fa48fea81280ad Mon Sep 17 00:00:00 2001 From: beauxq Date: Wed, 13 Sep 2023 14:40:09 -0700 Subject: [PATCH] annotation on anything that inherits directly from `Option` --- Options.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Options.py b/Options.py index fef375b6345a..4b11539510de 100644 --- a/Options.py +++ b/Options.py @@ -162,7 +162,7 @@ def verify(self, *args, **kwargs) -> None: class FreeText(Option[str]): """Text option that allows users to enter strings. Needs to be validated by the world or option definition.""" - default = "" + default: typing.ClassVar[typing.Union[str, typing.Literal["random"]]] = "" def __init__(self, value: str): assert isinstance(value, str), "value of FreeText must be a string" @@ -186,7 +186,7 @@ def get_option_name(cls, value: str) -> str: class NumericOption(Option[int], numbers.Integral, abc.ABC): - default = 0 + default: typing.ClassVar[typing.Union[int, typing.Literal["random"]]] = 0 # note: some of the `typing.Any`` here is a result of unresolved issue in python standards # `int` is not a `numbers.Integral` according to the official typestubs # (even though isinstance(5, numbers.Integral) == True) @@ -779,7 +779,7 @@ def verify(self, world: typing.Type[World], player_name: str, plando_options: "P class OptionDict(Option[typing.Dict[str, typing.Any]], VerifyKeys, typing.Mapping[str, typing.Any]): - default: typing.Dict[str, typing.Any] = {} + default: typing.ClassVar[typing.Dict[str, typing.Any]] = {} supports_weighting = False def __init__(self, value: typing.Dict[str, typing.Any]): @@ -820,7 +820,7 @@ class OptionList(Option[typing.List[typing.Any]], VerifyKeys): # If only unique entries are needed and input order of elements does not matter, OptionSet should be used instead. # Not a docstring so it doesn't get grabbed by the options system. - default: typing.List[typing.Any] = [] + default: typing.ClassVar[typing.List[typing.Any]] = [] supports_weighting = False def __init__(self, value: typing.List[typing.Any]): @@ -845,8 +845,8 @@ def __contains__(self, item): return item in self.value -class OptionSet(Option[typing.Set[str]], VerifyKeys): - default: typing.Union[typing.Set[str], typing.FrozenSet[str]] = frozenset() +class OptionSet(Option[typing.AbstractSet[str]], VerifyKeys): + default: typing.ClassVar[typing.AbstractSet[str]] = frozenset() supports_weighting = False def __init__(self, value: typing.Iterable[str]):