<commit_before>import warnings
from abc import ABCMeta
from copy import deepcopy
from pathlib import Path
from types import FunctionType
from typing import Any, Dict, Set, Type, Union

from .exceptions import ConfigError, Error, Extra, Missing, ValidationError
from .fields import Field, Validator
from .parse import Protocol, load_file, load_str_bytes
from .types import StrBytes
from .utils import truncate
from .validators import dict_validator


class BaseConfig:
    min_anystr_length = 0
    max_anystr_length = 2 ** 16
    min_number_size = -2 ** 64
    max_number_size = 2 ** 64
    validate_all = False
    ignore_extra = True
    allow_extra = False
    allow_mutation = True
    use_enum_values = False
    fields = {}
    validate_assignment = False


def inherit_config(self_config, parent_config) -> BaseConfig:
    if not self_config:
        return parent_config
    for k, v in parent_config.__dict__.items():
        if not (k.startswith('_') or hasattr(self_config, k)):
            setattr(self_config, k, v)
    return self_config


TYPE_BLACKLIST = FunctionType, property, type, classmethod, staticmethod


def _extract_validators(namespace):
    validators = {}
    for var_name, value in namespace.items():
        validator_config = getattr(value, '__validator_config', None)<commit_msg>fix type annotation of inherit_config function (#139)<commit_after>import warnings
from abc import ABCMeta
from copy import deepcopy
from pathlib import Path
from types import FunctionType
from typing import Any, Dict, Set, Type, Union

from .exceptions import ConfigError, Error, Extra, Missing, ValidationError
from .fields import Field, Validator
from .parse import Protocol, load_file, load_str_bytes
from .types import StrBytes
from .utils import truncate
from .validators import dict_validator


class BaseConfig:
    min_anystr_length = 0
    max_anystr_length = 2 ** 16
    min_number_size = -2 ** 64
    max_number_size = 2 ** 64
    validate_all = False
    ignore_extra = True
    allow_extra = False
    allow_mutation = True
    use_enum_values = False
    fields = {}
    validate_assignment = False


def inherit_config(self_config, parent_config) -> Type[BaseConfig]:
    if not self_config:
        return parent_config
    for k, v in parent_config.__dict__.items():
        if not (k.startswith('_') or hasattr(self_config, k)):
            setattr(self_config, k, v)
    return self_config


TYPE_BLACKLIST = FunctionType, property, type, classmethod, staticmethod


def _extract_validators(namespace):
    validators = {}
    for var_name, value in namespace.items():
        validator_config = getattr(value, '__validator_config', None)
{'fraction_non_alphanumeric': 0.07078651685393259, 'fraction_numerical': 0.008614232209737827, 'mean_word_length': 3.9554730983302413, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7343837', 'n_tokens_mistral': 803, 'n_tokens_neox': 768, 'n_words': 257}