Staging instance, all changes can be removed at any time

Skip to content

typing: minimal changes to make a no-op mypy run pass

This is a first, proof of concept diff showing how we can add mypy support to our modules. A second one is coming next, for swh-model. There is more where these come from, but I'd like to take the change of these first two to see if this is something we like and is useful.

Note that this is only to make a bare-bone mypy run pass cleanly, it does not add type annotations to the swh.core API. That can be done next, gradually; there is no hurry. Still, having mypy pass allows to detect glaring type errors, dunno, "1 + {}" expressions that would otherwise pass unnoticed.

About pre-buster Python compatibility: I'm using here comments for variable annotations instead of PEP 526 which requires Python >= 3.6. I'm doing so to avoid breaking production, but I don't know how to easily check that this is fully Python 3.5 compatible---independent testing on this point is very welcome.

Test Plan

tox -e mypy

(or just tox, as the environment is added to the default list of tox envs)


Migrated from D2015 (view on Phabricator)

Merge request reports

Loading