I recently ran into an odd bug where an inherited unit does not inherit the base classes STATE but does inherit it's SETTINGS. Importantly, this bug is only present in Python versions greater than 3.9. See below for a minimal example.
import ezmsg.core as ez
class BaseSettings(ez.Settings):
y: int = 10
class BaseState(ez.State):
x: int = 9
class BaseUnit(ez.Unit):
SETTINGS: BaseSettings
STATE: BaseState
async def initialize(self) -> None:
ez.logger.info(f"{self.SETTINGS=}, {self.STATE=}")
class ChildUnit(BaseUnit):
async def initialize(self) -> None:
ez.logger.info("In child")
ez.logger.info(f"{self.SETTINGS=}, {self.STATE=}")
return await super().initialize()
if __name__ == "__main__":
ez.run(ChildUnit())
Output on 3.9:
2024-07-15 13:18:26.014 - pid: 35744 - TaskThread - INFO - initialize: In child
2024-07-15 13:18:26.014 - pid: 35744 - TaskThread - INFO - initialize: self.SETTINGS=BaseSettings(y=10), self.STATE=BaseState(x=9)
2024-07-15 13:18:26.014 - pid: 35744 - TaskThread - INFO - initialize: self.SETTINGS=BaseSettings(y=10), self.STATE=BaseState(x=9)
2024-07-15 13:18:26.016 - pid: 35744 - MainThread - INFO - run: All processes exited normally
Output on 3.10:
2024-07-15 13:18:25.996 - pid: 35743 - TaskThread - INFO - initialize: In child
2024-07-15 13:18:25.996 - pid: 35743 - TaskThread - INFO - initialize: self.SETTINGS=BaseSettings(y=10), self.STATE=State()
2024-07-15 13:18:25.996 - pid: 35743 - TaskThread - INFO - initialize: self.SETTINGS=BaseSettings(y=10), self.STATE=State()
2024-07-15 13:18:25.997 - pid: 35743 - MainThread - INFO - run: All processes exited normally
I recently ran into an odd bug where an inherited unit does not inherit the base classes
STATE
but does inherit it'sSETTINGS
. Importantly, this bug is only present in Python versions greater than 3.9. See below for a minimal example.Output on 3.9:
Output on 3.10: