from typing import Optional
from typing import Any


def is_field_nullable(
    nullable: Optional[bool],
    default: Any,
    server_default: Any,
    pydantic_only: Optional[bool],
) -> bool:
    """
    Checks if the given field should be nullable/ optional based on parameters given.

    :param nullable: flag explicit setting a column as nullable
    :type nullable: Optional[bool]
    :param default: value or function to be called as default in python
    :type default: Any
    :param server_default: function to be called as default by sql server
    :type server_default: Any
    :param pydantic_only: flag if fields should not be included in the sql table
    :type pydantic_only: Optional[bool]
    :return: result of the check
    :rtype: bool
    """
    if nullable is None:
        return (
            default is not None
            or server_default is not None
            or (pydantic_only is not None and pydantic_only)
        )
    return nullable