make options an explicit kwarg

Signed-off-by: Panos Vagenas <pva@zurich.ibm.com>
This commit is contained in:
Panos Vagenas 2025-02-26 11:44:06 +01:00
parent 1553a125dc
commit 34393e51a2
4 changed files with 6 additions and 2 deletions

View File

@ -14,6 +14,8 @@ class BaseModelWithOptions(Protocol):
@classmethod
def get_options_type(cls) -> Type[BaseOptions]: ...
def __init__(self, *, options: BaseOptions, **kwargs): ...
class BasePageModel(ABC):
@abstractmethod

View File

@ -22,6 +22,7 @@ _log = logging.getLogger(__name__)
class BaseOcrModel(BasePageModel, BaseModelWithOptions):
def __init__(
self,
*,
enabled: bool,
artifacts_path: Optional[Path],
options: OcrOptions,

View File

@ -39,10 +39,10 @@ class BaseFactory(Generic[A], metaclass=ABCMeta):
def classes(self):
return self._classes
def create_instance(self, options: BaseOptions, *args, **kwargs) -> A:
def create_instance(self, options: BaseOptions, **kwargs) -> A:
try:
_cls = self._classes[type(options)]
return _cls(*args, **kwargs)
return _cls(options=options, **kwargs)
except KeyError:
raise RuntimeError(self._err_msg_on_class_not_found(options.kind))

View File

@ -32,6 +32,7 @@ class PictureDescriptionBaseModel(
def __init__(
self,
*,
enabled: bool,
enable_remote_services: bool,
artifacts_path: Optional[Union[Path, str]],