(annotation, base_module=None, *, quote_annotation_strings=True)
| 1337 | return ArgInfo(args, varargs, varkw, frame.f_locals) |
| 1338 | |
| 1339 | def formatannotation(annotation, base_module=None, *, quote_annotation_strings=True): |
| 1340 | if not quote_annotation_strings and isinstance(annotation, str): |
| 1341 | return annotation |
| 1342 | if getattr(annotation, '__module__', None) == 'typing': |
| 1343 | def repl(match): |
| 1344 | text = match.group() |
| 1345 | return text.removeprefix('typing.') |
| 1346 | return re.sub(r'[\w\.]+', repl, repr(annotation)) |
| 1347 | if isinstance(annotation, types.GenericAlias): |
| 1348 | return str(annotation) |
| 1349 | if isinstance(annotation, type): |
| 1350 | if annotation.__module__ in ('builtins', base_module): |
| 1351 | return annotation.__qualname__ |
| 1352 | return annotation.__module__+'.'+annotation.__qualname__ |
| 1353 | if isinstance(annotation, ForwardRef): |
| 1354 | return annotation.__forward_arg__ |
| 1355 | return repr(annotation) |
| 1356 | |
| 1357 | def formatannotationrelativeto(object): |
| 1358 | module = getattr(object, '__module__', None) |
no test coverage detected