Closed
Description
The following code fails to typecheck:
class A:
lol = None
class B(A):
lol = 'b'
with
test.py:5: error: Incompatible types in assignment (expression has type "str", base class "A" defined the type as "None")
My proposal for fixing this is to add a new flag, on by default, that will cause class variables with the type None
to instead be given the type Optional[Any]
.
Not sure what the flag should be called, though.
(I'm investigating top causes of errors when running mypy on an unannotated code base and this issue caused 60% of the 600+ errors generated when checking django.)