I'm writing a function that returns a tuple and using type annotations. To do so, I've written:
def foo(bar) -> Tuple[int, int]:
pass
This runs, but I've been getting a warning that says:
"Tuple" is not defined Pylance report UndefinedVariable
Given that I'm writing a number of functions that return a tuple type, I'd like to get rid of the warning. I'm assuming I just need to import the package Tuple refers to, but what is the right Python package for it?
From my research, I'm inclined to think it's the typing package, but I'm not sure.
Depending on your exact python version there might be subtle differences here, but what's bound to work is
from typing import Tuple
def foo(bar) -> Tuple[int, int]:
pass
Alternatively I think since 3.9 or 3.10 you can just outright say tuple[int, int] without importing anything.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With