[Python] To what extent does Google Colab support Python typing?

Discussão em 'Python' iniciado por Stack, Fevereiro 27, 2025.

  1. Stack

    Stack Membro Participativo

    I've entered code that had these lines.

    from typing import Dict, List, Set, Tuple

    def pairs_sum_to_k(a_set: Set[int], k: int) -> List[Tuple[int, int]]:
    ...


    The code compiled and ran. That's good. It's also good that when I attempted to import something that wasn't in typing Colab generated an error message.

    What's not good is that when the type hints were inconsistent with the program, , e.g., change the return type to a simple int, Colab didn't complain. This suggests that Colab can deal with type hint syntax, but that it doesn't do anything at all with the type declarations. Is that the case? What kind of typing support, if any, should I expect from Colab?

    Thanks.

    Continue reading...

Compartilhe esta Página