diff --git a/nest/core/pynest_factory.py b/nest/core/pynest_factory.py index 6f23fec..1271edf 100644 --- a/nest/core/pynest_factory.py +++ b/nest/core/pynest_factory.py @@ -1,26 +1,47 @@ -from abc import ABC, abstractmethod -from typing import Type, TypeVar +from typing import Type, TypeVar, overload, Union, Optional from nest.core.pynest_application import PyNestApp from nest.core.pynest_container import PyNestContainer from nest.engine.proto import App from nest.engine.fastapi import FastAPIApp + ModuleType = TypeVar("ModuleType") -# TODO: move default fastapi to here and add future implementation -class AbstractPyNestFactory(ABC): - @abstractmethod - def create(self, main_module: Type[ModuleType], **kwargs): - raise NotImplementedError +class PyNestFactory: + """Factory class for creating PyNest applications.""" + @staticmethod + @overload + def create( + main_module: Type[ModuleType], + app_cls: Type[FastAPIApp], + title: str = "", + description: str = "", + version: Optional[Union[str, int, float]] = None, + debug: bool = False, + ) -> PyNestApp: + """ + Create a PyNest application of FastAPIApp kind. + """ -class PyNestFactory(AbstractPyNestFactory): - """Factory class for creating PyNest applications.""" + @staticmethod + @overload + def create( + main_module: Type[ModuleType], + app_cls: Type[App], + ) -> PyNestApp: + """ + Create a PyNest application of FastAPIApp kind. + """ @staticmethod - def create(main_module: Type[ModuleType], app_cls: Type[App] = FastAPIApp, **kwargs) -> PyNestApp: + def create( + main_module: Type[ModuleType], + app_cls: Type[App] = FastAPIApp, + **kwargs + ) -> PyNestApp: """ Create a PyNest application with the specified main module class.