Create a base-class for every hydra setup possibility
This base-class can be used for IDEs and type-checkers at initialization
from mdml_tools.hydra_models.optimizer import BaseOptimizer
import hydra
optimizer: BaseOptimizer = hydra.utils.initialize(cfg.optimizer)
This way the IDE knows that every next reference to optimizer belongs to the optimizer class.
the BaseOptimizer could be something like this (pseudo-code):
from pytorch_lightning.optimizers import BasicOptimizer
class BaseOptimizer(BasicOptimizer):
pass
So the IDE knows its a torch optimizer, but when you follow the stack trace you will come back to where the hydra optimizers are created.
Edited by Tobias Schanz