What type-hint contains both list and tuple?

Your method is accepting a sequence, so use typing.Sequence. That’s a generic, so you can specify what type of object(s) the sequence must contain:

from typing import Sequence

def foo(bar: Sequence[int]):
    # bar is a sequence of integers

Quoting the Python glossary:

An iterable which supports efficient element access using integer indices via the __getitem__() special method and defines a __len__() method that returns the length of the sequence. Some built-in sequence types are list, str, tuple, and bytes.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)