3 Mar
2021
3 Mar
'21
12:36 p.m.
Sebastian Rittau wrote:
Use built-in generics instead of the aliases from typing. Yes:: def foo(x: type[MyClass]) -> list[str]: ...
No:: from typing import List, Type
def foo(x: Type[MyClass]) -> List[str]: ...
But:: from typing import Iterable
def foo(x: Iterable[str]) -> None: ...
According to PEP585, importing collection types from typing is deprecated, so wouldn't it be better to recommend importing things like Iterable from collections.abc?