def is_seq_of(seq, expected_type, seq_type=None):
if seq_type is None:<EOL><INDENT>exp_seq_type = collections_abc.Sequence<EOL><DEDENT>else:<EOL><INDENT>assert isinstance(seq_type, type)<EOL>exp_seq_type = seq_type<EOL><DEDENT>if not isinstance(seq, exp_seq_type):<EOL><INDENT>return False<EOL><DEDENT>for item in seq:<EOL><INDENT>if not isinstance(item, expected_type):<EOL><INDENT>return False<EOL><DEDENT><DEDENT>return True<EOL>
Check whether it is a sequence of some type.

    Args:
        seq (Sequence): The sequence to be checked.
        expected_type (type): Expected type of sequence items.
        seq_type (type, optional): Expected sequence type.

    Returns:
        bool: Whether the sequence is valid.