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

9 statements  

« prev     ^ index     » next       coverage.py v7.6.1, created at 2024-11-17 01:51 +0000

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

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

3 

4from typing import TypeVar 

5 

6from .cpp_classes import Variable 

7 

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

9 

10 

11def combine_dict_args( 

12 arg: 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}