#
# Copyright (c) Daniel Sheffield 2023
#
# All rights reserved
#
# THIS SOFTWARE IS PROVIDED AS IS WITHOUT WARRANTY
from decimal import Decimal, InvalidOperation
from typing import Any


def decimal_or_none(maybe_decimal: Any) -> Decimal:
    try:
        return Decimal(maybe_decimal)
    except InvalidOperation:
        return None