(self, typ)
| 744 | return tuple(self.translate(t) for t in self.types) |
| 745 | |
| 746 | def translate(self, typ): |
| 747 | t, args, metadata = _origin_args_metadata(typ) |
| 748 | |
| 749 | # Extract and merge components of any `Meta` annotations |
| 750 | constrs = {} |
| 751 | extra_json_schema = {} |
| 752 | extra = {} |
| 753 | for meta in metadata: |
| 754 | for attr in ( |
| 755 | "ge", |
| 756 | "gt", |
| 757 | "le", |
| 758 | "lt", |
| 759 | "multiple_of", |
| 760 | "pattern", |
| 761 | "min_length", |
| 762 | "max_length", |
| 763 | "tz", |
| 764 | ): |
| 765 | if (val := getattr(meta, attr)) is not None: |
| 766 | constrs[attr] = val |
| 767 | for attr in ("title", "description", "examples"): |
| 768 | if (val := getattr(meta, attr)) is not None: |
| 769 | extra_json_schema[attr] = val |
| 770 | if meta.extra_json_schema is not None: |
| 771 | extra_json_schema = _merge_json( |
| 772 | extra_json_schema, |
| 773 | _to_builtins(meta.extra_json_schema, str_keys=True), |
| 774 | ) |
| 775 | if meta.extra is not None: |
| 776 | extra.update(meta.extra) |
| 777 | |
| 778 | out = self._translate_inner(t, args, **constrs) |
| 779 | if extra_json_schema or extra: |
| 780 | # If extra metadata is present, wrap the output type in a Metadata |
| 781 | # wrapper object |
| 782 | return Metadata( |
| 783 | out, extra_json_schema=extra_json_schema or None, extra=extra or None |
| 784 | ) |
| 785 | return out |
| 786 | |
| 787 | def _translate_inner( |
| 788 | self, |
no test coverage detected