def resolve_annotations(raw_annotations: Dict[str, AnyType], module_name: Optional[str]) -> Dict[str, AnyType]:
    """
    Partially taken from typing.get_type_hints.

    Resolve string or ForwardRef annotations into type objects if possible.
    """
    if module_name:
        base_globals: Optional[Dict[str, Any]] = sys.modules[module_name].__dict__
    else:
        base_globals = None
    annotations = {}
    for name, value in raw_annotations.items():
        if isinstance(value, str):
            value = ForwardRef(value, is_argument=False)
        try:
            value = _eval_type(value, base_globals, None)
        except NameError:
            # this is ok, it can be fixed with update_forward_refs
            pass
        annotations[name] = value
    return annotations
def resolve_annotations ( raw_annotations : Dict [ str , AnyType ] , module_name : Optional [ str ] ) -> Dict [ str , AnyType ] : if module_name : base_globals : Optional [ Dict [ str , Any ] ] = sys . modules [ module_name ] . __dict__ else : base_globals = None annotations = { } for name , value in raw_annotations . items ( ) : if isinstance ( value , str ) : value = ForwardRef ( value , is_argument = False ) try : value = _eval_type ( value , base_globals , None ) except NameError : pass annotations [ name ] = value return annotations
Partially taken from typing.get_type_hints.

    Resolve string or ForwardRef annotations into type objects if possible.