Код: Выделить всё
def example(self, mydict: Dict[int, str] = None):
return mydict.get(1)
Код: Выделить всё
error: Incompatible default for argument "synonyms" (default has type "None", argument has type "Dict[Any, Any]") [assignment]
Код: Выделить всё
def example(self, myDict: Dict[int, str] = {}):
Код: Выделить всё
W0102: Dangerous default value {} as argument (dangerous-default-value)
РЕШЕНИЕ (на основе комментариев):
Код: Выделить всё
class Example:
"""Example"""
def __init__(self):
self.d: Optional[Dict[int, str]] = None
def example(self, mydict: Optional[Dict[int, str]] = None):
"""example"""
self.d = mydict
Подробнее здесь: https://stackoverflow.com/questions/721 ... aults-none