Skip to content

Commit

Permalink
CONTRIBUTING: Use PEP 604 syntax (#5925)
Browse files Browse the repository at this point in the history
Co-authored-by: Akuli <[email protected]>
  • Loading branch information
srittau and Akuli authored Aug 15, 2021
1 parent 0e62c8a commit 5f2e117
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -327,9 +327,10 @@ checker, and leave out unnecessary detail:

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, ...]`) (see
[python/mypy#9980](https://github.com/python/mypy/issues/9980));
of importing them from `typing`, **except** in type aliases, in base classes, and for
arbitrary length tuples (`Tuple[int, ...]`);
* use `X | Y` instead of `Union[X, Y]` and `X | None`, instead of
`Optional[X]`, **except** when it is not possible due to mypy bugs (type aliases and base classes);
* in Python 3 stubs, import collections (`Mapping`, `Iterable`, etc.)
from `collections.abc` instead of `typing`;
* avoid invariant collection types (`list`, `dict`) in argument
Expand Down

0 comments on commit 5f2e117

Please sign in to comment.