Page MenuHomeSoftware Heritage

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

Authored by zack on Sep 20 2019, 11:22 AM.

Details

Summary

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)

Diff Detail

Repository
rDCORE Foundations and core functionalities
Branch
feature/typing
Lint
No Linters Available
Unit
No Unit Test Coverage
Build Status
Buildable 7880
Build 11343: tox-on-jenkinsJenkins
Build 11342: arc lint + arc unit

Event Timeline

  • mypy: use conffile to ignore requests_mock
This revision is now accepted and ready to land.Sep 20 2019, 11:37 AM
  • mypy: ignore django-stubs, needed only by hypothesis