isinstance make mypy assume a too strong hypothesis on the type of the value, for example:
def foo(t : list[int | str]) -> int :
assert(isinstance(t[0], int))
t[0] = "coucou"
return t[0]
x : list[int | str] = [1, 2]
foo(x)
typechecks correctly while the type annotation is not correct.
isinstancemake mypy assume a too strong hypothesis on the type of the value, for example:typechecks correctly while the type annotation is not correct.