* Address issues found by ruff check. * Make mypy happy; remove some Python 2 compat code. * Also declare port1.