[Python] mypy fails with mixed types in variable length tuple

Discussão em 'Python' iniciado por Stack, Setembro 2, 2025.

  1. Stack

    Stack Membro Participativo

    mypy fails on code where a variable length tuple contains different types. What should I be doing here?

    for i, *s in [(1, 'a'), (2, 'b', 'c')]:
    print(hex(i), '_'.join(s))


    main.py:2: error: Argument 1 to "hex" has incompatible type "int | str"; expected "int | SupportsIndex" [arg-type]
    main.py:2: error: Argument 1 to "join" of "str" has incompatible type "list[int | str]"; expected "Iterable[str]" [arg-type]

    Continue reading...

Compartilhe esta Página