import typing


def extract_entity_types(line: dict) -> typing.List[str]:
    """Extracts the entity type(s) for an entity.

    Arguments:
        line: ``dict`` A line in the Wikidata dump.
    Returns:
        entity_types: ``list`` A list of entity types for the entity.
            Entity types are also QIDs in Wikidata.
    """
    entity_types = []
    # P31 is "instance of". We define these to represent entity types.
    for entry in line["claims"].get("P31", []):
        if (
            entry["mainsnak"]["datatype"] == "wikibase-item"
            and "datavalue" in entry["mainsnak"]
        ):
            entity_types.append(entry["mainsnak"]["datavalue"]["value"]["id"])
    return entity_types