from typing import Type
from typing import Any
from typing import Optional
from typing import Dict
import dataclasses


def _has_default_value(cls: Type[Any], field: str) -> Any:
    """Returns if the given field of a class has a default value (requires a
    @dataclass-based class, others will silently return 'False')
    """
    dataclass_fields: Optional[Dict] = getattr(
        cls, "__dataclass_fields__", None)
    if dataclass_fields:
        field_entry: Optional[dataclasses.Field] = dataclass_fields.get(
            field, None)
        if field_entry:
            has_value = field_entry.default is not dataclasses.MISSING
            has_factory = field_entry.default_factory is not dataclasses.MISSING
            return has_value or has_factory
    return False