-
-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder
Description
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.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-type-narrowingConditional type narrowing / binderConditional type narrowing / binder