Cleanup some type annotations. In particular, use the inline style of type annotations, rather than the comments, as this is what we do everywhere else. It will also make newer versions of mypy happier.
Change the pytest markers tryfirst/trylast to using hookimpl, since the former are deprecated and throw warnings on newer versions of pytest.