Annotate function that raises NameError like PEP 649 with undefined types.
(format: Format)
| 168 | from annotationlib import Format, ForwardRef |
| 169 | |
| 170 | def annotate_raises(format: Format) -> dict[str, object]: |
| 171 | """Annotate function that raises NameError like PEP 649 with undefined types.""" |
| 172 | if format == Format.VALUE: |
| 173 | raise NameError("name 'UndefinedType' is not defined") |
| 174 | if format == Format.STRING: |
| 175 | return string_annotations |
| 176 | # FORWARDREF format |
| 177 | return {k: ForwardRef(v) for k, v in string_annotations.items()} |
| 178 | |
| 179 | func = types.FunctionType( |
| 180 | base_func.__code__, # type: ignore[union-attr] |
nothing calls this directly
no test coverage detected
searching dependent graphs…