def _object_meta_fset(_, private_attr, type_):
    # type: (str, str, Type[_T]) -> Callable[[_T], None]
    """Create a property setter method for the attribute.

    Args:
        _: The name of the attribute to set. Unused.
        private_attr: The name of the attribute that will store any data
            related to the attribute.
        type_: The annotated type defining what values can be stored in the
            attribute.

    Returns:
        A method that takes self and a value and stores that value on self
        in the private attribute if the value is not an instance of type_
        and cannot be cast into type_.
    """

    def _fset(self, value):  # type: Any
        # type: (...) -> None
        """Set the value on self and coerce it to type_ if necessary.

        Args:
            value: The value to set.

        Raises:
            TypeError: Raised when the value is not an instance of type_
                and cannot be cast into a compatible object of type_.
        """
        rtype = type_
        if isinstance(type_, TypeVar):
            type_map = dict(
                zip(self.__parameters__, self.__orig_class__.__args__)
            )
            rtype = type_map[type_]
        vars(self)[private_attr] = cast(rtype, value)

    return _fset