Both typing
and collections.abc
includes similar type such as Mapping
, Sequence
, etc.
Based on the python documentation, it seems that collections.abc
is preferred for type checking:
This module provides abstract base classes that can be used to test whether a class provides a particular interface; for example, whether it is hashable or whether it is a mapping. https://docs.python.org/3/library/collections.abc.html
but using typing
also works and I'd rather not import Mapping
from both typing
and collections.abc
. So is there any catch in using typing
with isinstance()
?