(
    vals: types.AnyVal | Set[types.AnyVal],
    val_type: Type[Any] | Tuple[Type[Any], ...],
    valid_vals: Optional[Set[types.AnyVal]] = None,
)
return vals
Validate values that must be of a certain type and (optionally) found among
    a set of known valid values.

    Args:
        vals: Value or values to validate.
        val_type: Type(s) of which all ``vals`` must be instances.
        valid_vals: Set of valid values in which all ``vals`` must be found.

    Return:
        Set[obj]: Validated values.

    Raises:
        TypeError
        ValueError
Validate values that must be of a certain type and (optionally) found among
    a set of known valid values.
Validate values that must be of a certain type and ( optionally ) found among a set of known valid values .
def validate_set_members(
    vals: types.AnyVal | Set[types.AnyVal],
    val_type: Type[Any] | Tuple[Type[Any], ...],
    valid_vals: Optional[Set[types.AnyVal]] = None,
) -> Set[types.AnyVal]:
    """
    Validate values that must be of a certain type and (optionally) found among
    a set of known valid values.

    Args:
        vals: Value or values to validate.
        val_type: Type(s) of which all ``vals`` must be instances.
        valid_vals: Set of valid values in which all ``vals`` must be found.

    Return:
        Set[obj]: Validated values.

    Raises:
        TypeError
        ValueError
    """
    vals = cast(Set, to_collection(vals, val_type, set))
    if valid_vals is not None:
        if not isinstance(valid_vals, set):
            valid_vals = set(valid_vals)
        if not all(val in valid_vals for val in vals):
            raise ValueError(
                f"values {vals.difference(valid_vals)} are invalid; "
                f"valid values are {valid_vals}"
            )
    return vals
def validate_set_members ( vals : types . AnyVal | Set [ types . AnyVal ] , val_type : Type [ Any ] | Tuple [ Type [ Any ] , ... ] , valid_vals : Optional [ Set [ types . AnyVal ] ] = None , ) -> Set [ types . AnyVal ] : vals = cast ( Set , to_collection ( vals , val_type , set ) ) if valid_vals is not None : if not isinstance ( valid_vals , set ) : valid_vals = set ( valid_vals ) if not all ( val in valid_vals for val in vals ) : raise ValueError ( f"values {vals.difference(valid_vals)} are invalid; " f"valid values are {valid_vals}" ) return vals