# Path: mimesis/types.py
# JSON = Dict[str, Any]


import contextlib
import functools
import json
import operator
from functools import reduce
from pathlib import Path
from typing import Any, Generator, List, Optional
from mimesis.exceptions import NonEnumerableError
from mimesis.locales import Locale, validate_locale
from mimesis.random import Random, get_random_item
from mimesis.types import JSON, Seed

    def _setup_locale(self, locale: Locale = Locale.DEFAULT) -> None:
        """Set up locale after pre-check.

        :param str locale: Locale
        :raises UnsupportedLocale: When locale not supported.
        :return: Nothing.
        """

        locale_obj = validate_locale(locale)
        self.locale = locale_obj.value

    def extract(self, keys: List[str], default: Optional[Any] = None) -> Any:
        """Extracts nested values from JSON file by list of keys.

        :param keys: List of keys (order extremely matters).
        :param default: Default value.
        :return: Data.
        """

        if not keys:
            raise ValueError("List of keys cannot be empty.")

        try:
            if len(keys) == 1:
                return self._data[keys[0]]
            return reduce(operator.getitem, keys, self._data)
        except (TypeError, KeyError):
            return default


# Path: mimesis/types.py
# JSON = Dict[str, Any]


# Path: mimesis/providers/base.py
import contextlib
import functools
import json
import operator
from functools import reduce
from pathlib import Path
from typing import Any, Generator, List, Optional
from mimesis.exceptions import NonEnumerableError
from mimesis.locales import Locale, validate_locale
from mimesis.random import Random, get_random_item
from mimesis.types import JSON, Seed


    def _setup_locale(self, locale: Locale = Locale.DEFAULT) -> None:
        """Set up locale after pre-check.

        :param str locale: Locale
        :raises UnsupportedLocale: When locale not supported.
        :return: Nothing.
        """

        locale_obj = validate_locale(locale)
        self.locale = locale_obj.value

    def extract(self, keys: List[str], default: Optional[Any] = None) -> Any:
        """Extracts nested values from JSON file by list of keys.

        :param keys: List of keys (order extremely matters).
        :param default: Default value.
        :return: Data.
        """

        if not keys:
            raise ValueError("List of keys cannot be empty.")

        try:
            if len(keys) == 1:
                return self._data[keys[0]]
            return reduce(operator.getitem, keys, self._data)
        except (TypeError, KeyError):
            return default


    def _update_dict(self, initial: JSON, other: JSON) -> JSON: