Skip to content

Commit

Permalink
[docs] Show rationale
Browse files Browse the repository at this point in the history
  • Loading branch information
ftnext committed Oct 13, 2024
1 parent 1b02709 commit 3baf087
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,17 @@ Use abstract types instead of concrete ones
| KTH102 | Use `Iterable` or `Sequence` instead of `tuple` |
| KTH103 | Use `Iterable` instead of `set` |
| KTH104 | Use `Iterable` instead of `dict` |

## Rationale

https://docs.python.org/ja/3/library/typing.html#typing.List

>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`.
https://mypy.readthedocs.io/en/stable/cheat_sheet_py3.html#standard-duck-types

>Use Iterable for generic iterables (anything usable in "`for`"), and Sequence where a sequence (supporting "`len`" and "`__getitem__`") is required
https://typing.readthedocs.io/en/latest/reference/best_practices.html#arguments-and-return-types

>For arguments, prefer protocols and abstract types (`Mapping`, `Sequence`, `Iterable`, etc.).

0 comments on commit 3baf087

Please sign in to comment.