| 371 | return newargs |
| 372 | |
| 373 | def _deduplicate(params, *, unhashable_fallback=False): |
| 374 | # Weed out strict duplicates, preserving the first of each occurrence. |
| 375 | try: |
| 376 | return dict.fromkeys(params) |
| 377 | except TypeError: |
| 378 | if not unhashable_fallback: |
| 379 | raise |
| 380 | # Happens for cases like `Annotated[dict, {'x': IntValidator()}]` |
| 381 | new_unhashable = [] |
| 382 | for t in params: |
| 383 | if t not in new_unhashable: |
| 384 | new_unhashable.append(t) |
| 385 | return new_unhashable |
| 386 | |
| 387 | def _flatten_literal_params(parameters): |
| 388 | """Internal helper for Literal creation: flatten Literals among parameters.""" |