Шаг 1 из 4+130 XP
TypeVar bound и Self
Ограничения типов и возврат self.
bound
from typing import TypeVar
from numbers import Number
N = TypeVar("N", bound=Number)
def double(x: N) -> N:
return x*2 # type: ignoreОграничения типов и возврат self.
from typing import TypeVar
from numbers import Number
N = TypeVar("N", bound=Number)
def double(x: N) -> N:
return x*2 # type: ignore