Skip to content

Commit

Permalink
Recommend to use PEP 585
Browse files Browse the repository at this point in the history
  • Loading branch information
srittau committed Feb 23, 2021
1 parent dcd8764 commit 1d2d233
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,11 @@ checker, and leave out unnecessary detail:
* use `float` instead of `Union[int, float]`.

Some further tips for good type hints:
* use built-in generics (`list`, `dict`, `tuple`, `set`), instead
of importing them from `typing`, **except** for arbitrary length tuples
(`Tuple[int, ...]`);
* in Python 3 stubs, import collections (`Mapping`, `Iterable`, etc.)
from `collections.abc` instead of `typing`;
* avoid invariant collection types (`list`, `dict`) in argument
positions, in favor of covariant types like `Mapping` or `Sequence`;
* avoid Union return types: https://github.com/python/mypy/issues/1693;
Expand Down

0 comments on commit 1d2d233

Please sign in to comment.