Coverage for install/scipp/core/argument_handlers.py: 56%

9 statements  

« prev     ^ index     » next       coverage.py v7.4.0, created at 2024-04-28 01:28 +0000

1# SPDX-License-Identifier: BSD-3-Clause 

2# Copyright (c) 2023 Scipp contributors (https://github.com/scipp) 

3 

4from typing import Dict, TypeVar, Union 

5 

6from ..typing import Variable 

7 

8_ValueType = TypeVar('_ValueType', str, Variable) 

9 

10 

11def combine_dict_args( 

12 arg: Union[Dict[str, _ValueType], None], kwargs: Dict[str, _ValueType] 

13) -> Dict[str, _ValueType]: 

14 pos_dict = {} if arg is None else arg 

15 

16 overlapped = set(pos_dict).intersection(kwargs) 

17 if overlapped: 

18 raise ValueError( 

19 'The names passed in the dict and as keyword arguments must be distinct. ' 

20 f'Following names are used in both arguments: {overlapped}' 

21 ) 

22 

23 return {**pos_dict, **kwargs}