carpentries-incubator / carpentries-incubator/python-intermediate-development
section on type annotation
- Dominant language
- TeX
- Stars
- 63
- Forks
- 77
- Avg merge
- 20h 8m
- Merged PRs (30d)
- 3
Description
Hi, I'd like to contribute a section on type annotation in Python. The most logical place would be as a section 2.5 (shifting the optional exercises to 2.6). The section would take about one hour to teach, and teachers would have to choose to teach this over some other section. Overview:
1. Introduction to type annotation as a means of hardening code, early error detection, documentation and improving auto-completion.
2. Show type checker ecosystem: `mypy` (Guido), `pyright` (microsoft), `pyrefly` (meta), `ty` (astral).
3. Typing containers, type parameters.
4. Sum-types using the `|` operator, and product-types using dataclasses.
5. Abstract types: `Iterable`, `Callable`, `collections.abc`
6. Optional: generic types, protocols
Let me know what you think!
Contributor guide
Assessment
This issue has not been assessed yet.