[Python] Argument "attributes" to "clean" has incompatible type [arg-type] [closed]

Discussão em 'Python' iniciado por Stack, Janeiro 29, 2025.

  1. Stack

    Stack Membro Participativo

    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)


    I tried annotating variable a with Dict[str, bool | List[str]] as shown in above code but then it gives below errors -

    from line 1

    error: Dict entry 0 has incompatible type "str": "Callable[[str, str, str], bool]"; expected "str": "Union[bool, list[str]]" [dict-item]


    from line 9

    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]

    Continue reading...

Compartilhe esta Página