Skip to content

Commit 3baf087

Browse files
committed
[docs] Show rationale
1 parent 1b02709 commit 3baf087

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,17 @@ Use abstract types instead of concrete ones
4848
| KTH102 | Use `Iterable` or `Sequence` instead of `tuple` |
4949
| KTH103 | Use `Iterable` instead of `set` |
5050
| KTH104 | Use `Iterable` instead of `dict` |
51+
52+
## Rationale
53+
54+
https://docs.python.org/ja/3/library/typing.html#typing.List
55+
56+
>Note that to annotate arguments, it is preferred to use an abstract collection type such as `Sequence` or `Iterable` rather than to use `list` or `typing.List`.
57+
58+
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#standard-duck-types
59+
60+
>Use Iterable for generic iterables (anything usable in "`for`"), and Sequence where a sequence (supporting "`len`" and "`__getitem__`") is required
61+
62+
https://typing.readthedocs.io/en/latest/reference/best_practices.html#arguments-and-return-types
63+
64+
>For arguments, prefer protocols and abstract types (`Mapping`, `Sequence`, `Iterable`, etc.).

0 commit comments

Comments
 (0)