def handle_annotated_type(ctx: AnalyzeTypeContext, fullname: str) -> MypyType:
    """
    Replaces the 'WithAnnotations' type with a type that can represent an annotated
    model.
    """
    is_with_annotations = fullname == fullnames.WITH_ANNOTATIONS_FULLNAME
    args = ctx.type.args
    if not args:
        return AnyType(TypeOfAny.from_omitted_generics) if is_with_annotations else ctx.type
    type_arg = get_proper_type(ctx.api.analyze_type(args[0]))
    if not isinstance(type_arg, Instance) or not helpers.is_model_type(type_arg.type):
        return type_arg

    fields_dict = None
    if len(args) > 1:
        second_arg_type = get_proper_type(ctx.api.analyze_type(args[1]))
        if isinstance(second_arg_type, TypedDictType) and is_with_annotations:
            fields_dict = second_arg_type
        elif isinstance(second_arg_type, Instance) and second_arg_type.type.fullname == ANNOTATIONS_FULLNAME:
            annotations_type_arg = get_proper_type(second_arg_type.args[0])
            if isinstance(annotations_type_arg, TypedDictType):
                fields_dict = annotations_type_arg
            elif not isinstance(annotations_type_arg, AnyType):
                ctx.api.fail("Only TypedDicts are supported as type arguments to Annotations", ctx.context)
            elif annotations_type_arg.type_of_any == TypeOfAny.from_omitted_generics:
                ctx.api.fail("Missing required TypedDict parameter for generic type Annotations", ctx.context)

    if fields_dict is None:
        return type_arg

    assert isinstance(ctx.api, TypeAnalyser)
    assert isinstance(ctx.api.api, SemanticAnalyzer)
    return get_annotated_type(ctx.api.api, type_arg, fields_dict=fields_dict)

    Replaces the 'WithAnnotations' type with a type that can represent an annotated
    model.
    
mypy_django_plugin/transformers/models.py