You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This clashes with truthy-bool error code, which assumes that subtypes won't implement these methods.
fromtypingimportfinal@finalclassA:
b: intifA():
print("hi") # no unreachable errorprint(A() and"hi")
Any instance of A will never have a __bool__ or __len__, method so these condition will always test true.
More real life scenario:
fromtypingimportfinal@finalclassA:
b: inta: A|Noner1: int|None=a.bifaelseNoner2: int|None=aanda.b# error: Incompatible types in assignment (expression has type "Union[A, None, int]", variable has type "Optional[int]")