Fix some typing issues uncovered by upgrading mypy to 1.11.x.