-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
false-positivemypy gave an error on correct codemypy gave an error on correct codeneeds discussionpriority-0-high
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.)
Metadata
Metadata
Assignees
Labels
false-positivemypy gave an error on correct codemypy gave an error on correct codeneeds discussionpriority-0-high