from typing import Union from io import TextIOWrapper import json def compose_config( config: Union[TextIOWrapper, None], credentials: Union[TextIOWrapper, None], queries: Union[TextIOWrapper, None], ) -> dict: """ Receive the CLI arguments and compose a session config. :param config: file pointer to a full config file. :param credentials: file pointer to a credentials file. :param queries: file pointer to a queries file. :return: a dict with the composed configuration. """ if config is not None: DeprecationWarning( "Usage of a full config file will be deprecated. Instead, use the credentials and queries arguments." ) return json.load(config) if credentials is None or queries is None: raise ValueError( "You need to provide both --credentials and --queries arguments." ) # Merge both into one dict so it follows the same structure as a full config file return {**json.load(credentials), **json.load(queries)}