a: Dict[str, bool | List[str]] = { # line 1
'a': true,
'b': ['text'],
'c': []
}
b = a.copy();
bleach.clean( # line 9
'string', tags=tag_names, attributes=b, strip=True)
Я попробовал аннотировать переменную A с DICT [Str, Bool | Список [str]] , как показано в вышеуказанном коде, но затем приведены ниже ошибки -
из строки 1
error: Dict entry 0 has incompatible type "str": "Callable[[str, str, str], bool]"; expected "str": "Union[bool, list[str]]" [dict-item]
< /code>
из строки 9 < /p>
Argument "attributes" to "clean" has incompatible type "dict[str, Union[bool, list[str]]]"; expected "Union[Callable[[str, str, str], bool], Union[dict[str, Union[list[str], Callable[[str, str, str], bool]]], dict[str, list[str]], dict[str, Callable[[str, str, str], bool]]], list[str]]" [arg-type]
Подробнее здесь: https://stackoverflow.com/questions/793 ... e-arg-type