from typing import Mapping


def get_attribute(obj, attr_name):
    """
    Return object attribute. Can work with dictionaries.

    :param object obj: Object for search attribute.
    :param str attr_name: Attribute name.

    :return: Found attribute or exception.
    :rtype: object

    :raise AttributeError: If attribute not found.

    """
    # Search attribute.
    if isinstance(obj, Mapping):
        attr = obj[attr_name]
    else:
        attr = getattr(obj, attr_name)

    # Return.
    return attr