Return a dict from a list of config strings. This is where we parse CLI configuration. Each item should have the form ``"key=value"``. item parsing is done in :meth:`.item_from_string`.
(self, s_list: list[str])
| 4074 | raise |
| 4075 | |
| 4076 | def from_string_list(self, s_list: list[str]) -> t.Any: |
| 4077 | """Return a dict from a list of config strings. |
| 4078 | |
| 4079 | This is where we parse CLI configuration. |
| 4080 | |
| 4081 | Each item should have the form ``"key=value"``. |
| 4082 | |
| 4083 | item parsing is done in :meth:`.item_from_string`. |
| 4084 | """ |
| 4085 | if len(s_list) == 1 and s_list[0] == "None" and self.allow_none: |
| 4086 | return None |
| 4087 | if len(s_list) == 1 and s_list[0].startswith("{") and s_list[0].endswith("}"): |
| 4088 | warn( |
| 4089 | f"--{self.name}={s_list[0]} for dict-traits is deprecated in traitlets 5.0. " |
| 4090 | f"You can pass --{self.name} <key=value> ... multiple times to add items to a dict.", |
| 4091 | DeprecationWarning, |
| 4092 | stacklevel=2, |
| 4093 | ) |
| 4094 | |
| 4095 | return literal_eval(s_list[0]) |
| 4096 | |
| 4097 | combined = {} |
| 4098 | for d in [self.item_from_string(s) for s in s_list]: |
| 4099 | combined.update(d) |
| 4100 | return combined |
| 4101 | |
| 4102 | def item_from_string(self, s: str) -> dict[K, V]: |
| 4103 | """Cast a single-key dict from a string. |
no test coverage detected