torch/jit/annotations.py
def try_real_annotations(fn):
    """Tries to use the Py3.5+ annotation syntax to get the type."""
    try:
        sig = inspect.signature(fn)
    except ValueError:
        return None

    all_annots = [sig.return_annotation] + [p.annotation for p in sig.parameters.values()]
    if all(ann is sig.empty for ann in all_annots):
        return None

    def as_ann(ann):
        # sig.empty is really annoying so convert it to None
        return ann if ann is not sig.empty else None

    arg_types = [ann_to_type(as_ann(p.annotation))
                 for p in sig.parameters.values()]
    return_types = flatten_return_type(ann_to_type(as_ann(sig.return_annotation)))
    return arg_types, return_types
Tries to use the Py3.5+ annotation syntax to get the type.
Tries to use the Py3.5+ annotation syntax to get the type.
Tries to use the Py3 . 5 + annotation syntax to get the type .
def try_real_annotations(fn):
    try:
        sig = inspect.signature(fn)
    except ValueError:
        return None
    all_annots = [sig.return_annotation] + [p.annotation for p in sig.parameters.values()]
    if all(ann is sig.empty for ann in all_annots):
        return None
    def as_ann(ann):
        return ann if ann is not sig.empty else None
    arg_types = [ann_to_type(as_ann(p.annotation))
                 for p in sig.parameters.values()]
    return_types = flatten_return_type(ann_to_type(as_ann(sig.return_annotation)))
    return arg_types, return_types
def try_real_annotations ( fn ) : try : sig = inspect . signature ( fn ) except ValueError : return None all_annots = [ sig . return_annotation ] + [ p . annotation for p in sig . parameters . values ( ) ] if all ( ann is sig . empty for ann in all_annots ) : return None def as_ann ( ann ) : return ann if ann is not sig . empty else None arg_types = [ ann_to_type ( as_ann ( p . annotation ) ) for p in sig . parameters . values ( ) ] return_types = flatten_return_type ( ann_to_type ( as_ann ( sig . return_annotation ) ) ) return arg_types , return_types
Tries to use the Py3.5+ annotation syntax to get the type.
Tries to use the Py3 . 5 + annotation syntax to get the type .
"""Tries to use the Py3.5+ annotation syntax to get the type.""" # sig.empty is really annoying so convert it to None
fn