Closed
Description
I have this snippet of code
from typing import Any,List
class Node:
def __init__(self, value:Any, *, children:List['Node']=None) -> None:
self.value = value
self.children = [] if children is None else children # type: List[Node]
if I use mypy I get
Tree.py: note: In member "__init__" of class "Node":
Tree.py:10: error: Incompatible types in assignment (expression has type "object", variable has type List[Node])
I think it's something related to the children parameter setted to None, but the problem is... how do I specify that yes, maybe the children parameter can be None, but self.children, by construction is always a List of Nodes?