import dataclasses
import copy


def _unpack_field(field: dataclasses.Field) -> dataclasses.Field:
    """Extract the type contained inside the generic definition.

    Replaces the field's type with the type contained inside its generic type, e.g.: List[int] -> int

    The returned field is a copy of the original, as the original resides in the class definition. Modifying it would be
    destructive.
    """
    new_field = copy.copy(field)
    new_field.type = field.type.__args__[0]
    return new_field