Typing list[T] in a generic function python
There is a problem that I have come across in python that the List type is invariant – meaning that it can only hold objects of a specific type or you will get a type error (for example when running mypy) – but sometimes you need to use a collection in a more generic function. A clear example is this
Generic collection in python Sequence vs List vs bounded type
There is a problem that I have come across in python that the List type is invariant – meaning that it can only hold objects of a specific type or you will get a type error (for example when running mypy) – but sometimes you need to use a collection in a more generic function. A clear example is this