Fix mypy typing errors
MR !6 (merged) fixes a lot of pre-commit errors but left some mypy errors. This commit fixes them: most of the fixes do not change the semantics (they are just here to calm mypy).
I am uneasy with api.unwrap
: in Python, x.v
raises an exception if
x
is None
, and sometimes we want that (if x
is None
, then
there is a problem and we want an exception to fail in this
case). When x
is of type Optional[T]
, mypy
requires to check
that x
is not None
: that is the point of the function
api.unwrap.unwrap
, but that breaks Python's tradition of "Ask
forgiveness not permission".