Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5f2e117

Browse files
srittauAkuli
andauthored
CONTRIBUTING: Use PEP 604 syntax (#5925)
Co-authored-by: Akuli <[email protected]>
1 parent 0e62c8a commit 5f2e117

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

CONTRIBUTING.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -327,9 +327,10 @@ checker, and leave out unnecessary detail:
327327

328328
Some further tips for good type hints:
329329
* use built-in generics (`list`, `dict`, `tuple`, `set`), instead
330-
of importing them from `typing`, **except** for arbitrary length tuples
331-
(`Tuple[int, ...]`) (see
332-
[python/mypy#9980](https://github.com/python/mypy/issues/9980));
330+
of importing them from `typing`, **except** in type aliases, in base classes, and for
331+
arbitrary length tuples (`Tuple[int, ...]`);
332+
* use `X | Y` instead of `Union[X, Y]` and `X | None`, instead of
333+
`Optional[X]`, **except** when it is not possible due to mypy bugs (type aliases and base classes);
333334
* in Python 3 stubs, import collections (`Mapping`, `Iterable`, etc.)
334335
from `collections.abc` instead of `typing`;
335336
* avoid invariant collection types (`list`, `dict`) in argument

0 commit comments

Comments
 (0)