Page MenuHomeSoftware Heritage

typing: type annotate

Authored by zack on Sep 20 2019, 2:42 PM.



Upping the ante from D2015 / D2016, this diff is a proof of concept of what it
takes to annotate an actual module, making types visible for all functions /
methods. I'm using as guinea pig swh-graph, as it is largely independent from
the rest and only requires swh-{core,model} which are already (minimally)

To avoid duplication of typing information, I'm removing here types from
docstring and moving them to proper type annotations. I'm not exactly sure yet
what Sphinx rendering (with Napoleon style) will do with type annotations...

Test Plan


Diff Detail

rDGRPH Graph service
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

zack created this revision.Sep 20 2019, 2:42 PM
vlorentz added inline comments.
87–95 ↗(On Diff #6785)

did you check sphinx reads the new type annotations?

zack added inline comments.Sep 20 2019, 2:56 PM
87–95 ↗(On Diff #6785)

answer is in this diff's summary :-)

vlorentz accepted this revision.Sep 20 2019, 3:33 PM

It does

This revision is now accepted and ready to land.Sep 20 2019, 3:33 PM
zack added a comment.Sep 20 2019, 3:55 PM

It does

thanks a lot for checking (and YAY !)

zack updated this revision to Diff 6787.Sep 20 2019, 4:00 PM
  • ship py.typed