-
Notifications
You must be signed in to change notification settings - Fork 263
Open
Labels
topic: documentationDocumentation-related issues and PRsDocumentation-related issues and PRs
Description
Thoughts on the tutorial document.
Basic Topics
- Set up a basic venv with a pinned mypy version. (For compatibility reasons.) Should add a note about using a current version in production.
- Annotating variables.
- Annotating functions and methods.
- Unions, using
| None
Any
cast()
and# type: ignore
- Using generics, variance
- Built-in collections
- Type aliases
int
/float
NoReturn
(not strictly necessary, but a fairly easy topic)- Installing third-party stubs
Advanced Topics
The are fairly complicated topics, but basically required when typing a non-trivial code base:
Callable
- Writing generics
- Protocols
type[...]
typing.TYPE_CHECKING
and circular importsTypeVar
andAnyStr
- overloads
Literal
What not to include
# type
annotations (except# type: ignore
)
The following topics could arguably be included, but for simplicity's sake, I'd suggest to skip them in this basic tutorial:
NewType
ClassVar
Final
Annotated
NamedTuple
TypedDict
Other Thoughts
- We can use a newer version of Python (e.g. 3.8+) for simplicity and add a note that not all features are available in older Python versions.
- We should probably just use
from __future__ import annotations
and skip the whole forward references/quoting types problem.
Metadata
Metadata
Assignees
Labels
topic: documentationDocumentation-related issues and PRsDocumentation-related issues and PRs