-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrongpriority-0-hightopic-pep-572PEP 572 (walrus operator)PEP 572 (walrus operator)
Description
Example from @gvanrossum in #6899:
from typing import Optional
class C:
def foo(self):
pass
def good(b: Optional[C]) -> None:
a = b
if a:
a.foo()
def bad(b: Optional[C]) -> None:
if a := b:
a.foo() # E: Item "None" of "Optional[C]" has no attribute "foo"
jamesmcm, kelseyfrancis, aleksanb, unmade, je-l and 2 morealeksanb, coiax and nayanex
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongpriority-0-hightopic-pep-572PEP 572 (walrus operator)PEP 572 (walrus operator)