ats_utilities.factory_component module¶
- Module
factory_component.py
- Copyright
Copyright (C) 2017 - 2026 Vladimir Roncevic <elektron.ronca@gmail.com> ats_utilities is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. ats_utilities is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see <http://www.gnu.org/licenses/>.
- Info
Factory universally create and validate component instantiation. Encapsulates core utilities to minimize constructor overhead. Provides a simple factory mechanism for dependency injection.
- ats_utilities.factory_component.make_component(passed_obj: Any, default_class: Any, factory_args: dict[str, Any] | None = None) Any[source]¶
Creates a component instance or returns an existing one.
- Parameters:
passed_obj (<Any>) – An existing component instance or None.
default_class (<Any>) – The class to instantiate if passed_obj is None.
factory_args (<dict[str, Any] | None>) – Arguments to pass to the default_class constructor | None.
- Returns:
An instance of the component.
- Return type:
<Any>
- Exceptions:
None.
- ats_utilities.factory_component.validate_component(instance: Any, expected_class: type[Any]) None[source]¶
Validates if a component instance is of the expected class type.
- Parameters:
instance (<Any>) – The resolved component instance to check.
expected_class (<type[Any]>) – The expected concrete class type.
- Exceptions:
ATSTypeError