use-types-from-typing¶
Enforces the use of types from the typing module in type annotations in place
of builtins.{builtin_type} since the type system doesn’t recognize the latter
as a valid type before Python 3.10.
Valid examples¶
def function(list: List[str]) -> None:
pass
def function() -> None:
thing: Dict[str, str] = {}
def function() -> None:
thing: Tuple[str]
Show more
from typing import Dict, List
def function() -> bool:
return Dict == List
from typing import List as list
from graphene import List
def function(a: list[int]) -> List[int]:
return []
Invalid examples¶
from typing import List
def whatever(list: list[str]) -> None:
pass
Suggested fix
from typing import List
def whatever(list: List[str]) -> None:
pass
Show more
def function(list: list[str]) -> None:
pass
def func() -> None:
thing: dict[str, str] = {}
def func() -> None:
thing: tuple[str]
from typing import Dict
def func() -> None:
thing: dict[str, str] = {}
Suggested fix
from typing import Dict
def func() -> None:
thing: Dict[str, str] = {}