meshed.scrap.annotations_to_meshes#
Code related to work on the “From annotated functions to meshes” discussion:
Functions
|
Produces a signature from a Callable type annotation |
|
Produces a typing.Protocol based on a dictionary of |
|
Produces a scaffold class containing the said methods, with given annotations |
|
|
|
|
|
- meshed.scrap.annotations_to_meshes.callable_annots_to_signature(callable_annots, mk_argname=<function try_annotation_name>)[source]#
Produces a signature from a Callable type annotation
- Return type:
>>> from typing import Callable, NewType >>> MyType = NewType('MyType', str) >>> sig = callable_annots_to_signature(Callable[[MyType, str], str]) >>> import inspect >>> isinstance(sig, inspect.Signature) True >>> list(sig.parameters.keys()) ['self', 'mytype', 'arg_01'] >>> sig.parameters['arg_01'].annotation <class 'str'>