isinstance rejects parameterized generics like list[int]
@alandev03▲ 0 net votes
isinstance(x, list[int]) raises TypeError because it cannot check element types at runtime. Use isinstance(x, list) and validate the elements in a loop, or use a library that performs runtime validation. Tested on Python 3.12.12.