(annotation, base_module=None, *, quote_annotation_strings=True)
| 1361 | return ArgInfo(args, varargs, varkw, frame.f_locals) |
| 1362 | |
| 1363 | def formatannotation(annotation, base_module=None, *, quote_annotation_strings=True): |
| 1364 | if not quote_annotation_strings and isinstance(annotation, str): |
| 1365 | return annotation |
| 1366 | if getattr(annotation, '__module__', None) == 'typing': |
| 1367 | def repl(match): |
| 1368 | text = match.group() |
| 1369 | return text.removeprefix('typing.') |
| 1370 | return re.sub(r'[\w\.]+', repl, repr(annotation)) |
| 1371 | if isinstance(annotation, types.GenericAlias): |
| 1372 | return str(annotation) |
| 1373 | if isinstance(annotation, type): |
| 1374 | if annotation.__module__ in ('builtins', base_module): |
| 1375 | return annotation.__qualname__ |
| 1376 | return annotation.__module__+'.'+annotation.__qualname__ |
| 1377 | if isinstance(annotation, ForwardRef): |
| 1378 | return annotation.__forward_arg__ |
| 1379 | return repr(annotation) |
| 1380 | |
| 1381 | def formatannotationrelativeto(object): |
| 1382 | module = getattr(object, '__module__', None) |
no test coverage detected
searching dependent graphs…