I am using an open source project where I can write code pieces in a GUI at several entry points and then it generates a complete python script with a class and appropriate methods. Entry points are:
- to add libraries imports
- to add code in the class _init_ method
- to add code in the so called ConditionalRun method which is executed periodically in an automation controller
I need to add methods to this class, but unfortunately, there is no inside class entry point to add methods nor attributes. I have opened an issue to add it, but I need a quick workaround.
I know I can use the typing library to forward declare the class I can localize in the import entry point:
import typing # cf https://www.delftstack.com/howto/python/forward-declaration-in-python/
ConditionalRun = typing.NewType("ConditionalRun", AbstractConditional)
But I need to also forward define my methods. Is it possible?
As an ultimate workaround, I can edit the generated code, but it is not convenient.