| 349 | return newargs |
| 350 | |
| 351 | def _deduplicate(params, *, unhashable_fallback=False): |
| 352 | # Weed out strict duplicates, preserving the first of each occurrence. |
| 353 | try: |
| 354 | return dict.fromkeys(params) |
| 355 | except TypeError: |
| 356 | if not unhashable_fallback: |
| 357 | raise |
| 358 | # Happens for cases like `Annotated[dict, {'x': IntValidator()}]` |
| 359 | new_unhashable = [] |
| 360 | for t in params: |
| 361 | if t not in new_unhashable: |
| 362 | new_unhashable.append(t) |
| 363 | return new_unhashable |
| 364 | |
| 365 | def _flatten_literal_params(parameters): |
| 366 | """Internal helper for Literal creation: flatten Literals among parameters.""" |