Reverse the mapping used to lazy loading, and check for conflicting name. Args: mapping: The mapping to reverse. Returns: The reversed mapping.
(mapping: dict[str, list])
| 298 | |
| 299 | |
| 300 | def _reverse_mapping(mapping: dict[str, list]) -> dict[str, str]: |
| 301 | """Reverse the mapping used to lazy loading, and check for conflicting name. |
| 302 | |
| 303 | Args: |
| 304 | mapping: The mapping to reverse. |
| 305 | |
| 306 | Returns: |
| 307 | The reversed mapping. |
| 308 | """ |
| 309 | reversed_mapping = {} |
| 310 | for key, values in mapping.items(): |
| 311 | for value in values: |
| 312 | if value not in reversed_mapping: |
| 313 | reversed_mapping[value] = key |
| 314 | else: |
| 315 | console.warn( |
| 316 | f"Key {value} is present multiple times in the imports _MAPPING: {key} / {reversed_mapping[value]}" |
| 317 | ) |
| 318 | return reversed_mapping |
| 319 | |
| 320 | |
| 321 | # _MAPPING = {value: key for key, values in _MAPPING.items() for value in values} |