| 936 | klass = dict |
| 937 | |
| 938 | def __init__(self, /, *args: Any, **kwargs: Any): |
| 939 | if args: |
| 940 | assert not kwargs |
| 941 | if len(args) == 1: |
| 942 | args = args[0] |
| 943 | if isinstance(args, dict): # type: ignore[unreachable] |
| 944 | args = tuple(itertools.chain(*args.items())) # type: ignore[unreachable] |
| 945 | elif isinstance(args, (list, tuple)): |
| 946 | if all( |
| 947 | len(el) == 2 if isinstance(el, (list, tuple)) else False |
| 948 | for el in args |
| 949 | ): |
| 950 | args = tuple(itertools.chain(*args)) |
| 951 | else: |
| 952 | raise ValueError("Invalid argument provided") |
| 953 | |
| 954 | if len(args) % 2 != 0: |
| 955 | raise ValueError("Invalid number of arguments provided") |
| 956 | |
| 957 | elif kwargs: |
| 958 | assert not args |
| 959 | args = tuple(itertools.chain(*kwargs.items())) |
| 960 | |
| 961 | super().__init__(*args) |
| 962 | |
| 963 | def __repr__(self): |
| 964 | values = ", ".join(f"{k}: {v}" for k, v in batched(self.args, 2, strict=True)) |