Skip to content
Snippets Groups Projects

BIG flow3r

Merged rahix requested to merge rahix/big-flow3r into main
Files
3
@@ -171,7 +171,7 @@ class NumberTunable(UnaryTunable):
NumberTunable is a UnaryTunable that has a numeric value
"""
def __init__(self, name: str, key: str, default: Optional[int | float]) -> None:
def __init__(self, name: str, key: str, default: Optional[float]) -> None:
    • Comment on lines -174 to +174
      Maintainer

      What's this change about? It doesn't seem right.

      • Author Owner

        Optional[int | float] is not a valid type annotation. I've changed it to just float because an int should be viewed as a subclass of float for typing purposes. But even if you wanted to express the union, the correct syntax would have been Optional[Union[int, float]], or the equivalent Union[int, float, None].

        The only reason I touched this code at all is that the regular python interpreter throws an exception when trying to evaluate this annotation as part of running the simulator.

      • Maintainer

        Optional[int | float] is a valid type annotation and the simulator works fine with it (otherwise CI would be broken on main right now). Union type expressions were introduced with Python 3.10 in 2021 (PEP 604). If you want to make it compatible with Python < 3.10 then go on, though it may be worth editing the commit message to be less confusing.

        So https://peps.python.org/pep-0484/#the-numeric-tower states that float alone will, indeed, already cover int. Personally I'd prefer having it explicit, but my initial worry was that it's wrong - and it's not 🤪️

      • Please register or sign in to reply
Please register or sign in to reply
super().__init__(name, key, default)
def press(self, vm: Optional["ViewManager"]) -> None:
Loading