Mercurial > hg
view CONTRIBUTORS @ 51671:6fc31e7bd5db
typing: add some type hints for bundle2 capabilities
Somewhere between hg 3dbc7b1ecaba and hg 8e3f6b5bf720, pytype determined the
signature of `bundle20.capabilities` changed from `Dict[bytes, Tuple[bytes]]` to
`Dict[bytes, Union[List[bytes], Tuple[bytes]]]`.
First, I did try to simply be explicit about the previously inferred type, but
it does seem to mix and match list/tuple now (e.g. in `writenewbundle()`). I
tried changing the new list usage to tuple, but a couple of things complained,
(and I think lists of one item are a little more clear to read anyway). So then
I typed the dict value as `Sequence[bytes]`, which worked fine. But there's
also a module level `capabilities` field, and when that's typed, pytype
complains about `Sequence[bytes]` lacking `__add__`[1]. So I gave up, and just
assigned it the type it wanted, with an alias. If somebody feels motivated to
make the type consistent, it's simple enough to change the alias.
The mutable default value to the constructor was removed to appease PyCharm's
type checking on the field. (I didn't bother running the code through pytype
prior to changing it, because we've previously made an effort to remove this
pattern anyway.)
I'm not sure why `getrepocaps()` has a default value for `role` that apparently
raises an exception. It's just flagged for now so this series can land without
risking additional problems.
[1] https://foss.heptapod.net/mercurial/mercurial-devel/-/jobs/2466903
author | Matt Harbison <matt_harbison@yahoo.com> |
---|---|
date | Wed, 10 Jul 2024 17:09:34 -0400 |
parents | c29efd272395 |
children |
line wrap: on
line source
[This file is here for historical purposes, all recent contributors should appear in the changelog directly] Andrea Arcangeli <andrea at suse.de> Thomas Arendsen Hein <thomas at intevation.de> Goffredo Baroncelli <kreijack at libero.it> Muli Ben-Yehuda <mulix at mulix.org> Mikael Berthe <mikael at lilotux.net> Benoit Boissinot <bboissin at gmail.com> Brendan Cully <brendan at kublai.com> Vincent Danjean <vdanjean.ml at free.fr> Jake Edge <jake at edge2.net> Michael Fetterman <michael.fetterman at intel.com> Edouard Gomez <ed.gomez at free.fr> Eric Hopper <hopper at omnifarious.org> Alecs King <alecsk at gmail.com> Volker Kleinfeld <Volker.Kleinfeld at gmx.de> Vadim Lebedev <vadim at mbdsys.com> Christopher Li <hg at chrisli.org> Chris Mason <mason at suse.com> Colin McMillen <mcmillen at cs.cmu.edu> Wojciech Milkowski <wmilkowski at interia.pl> Chad Netzer <chad.netzer at gmail.com> Bryan O'Sullivan <bos at serpentine.com> Vicent SeguĂ Pascual <vseguip at gmail.com> Sean Perry <shaleh at speakeasy.net> Nguyen Anh Quynh <aquynh at gmail.com> Ollivier Robert <roberto at keltia.freenix.fr> Alexander Schremmer <alex at alexanderweb.de> Arun Sharma <arun at sharma-home.net> Josef "Jeff" Sipek <jeffpc at optonline.net> Kevin Smith <yarcs at qualitycode.com> TK Soh <teekaysoh at yahoo.com> Radoslaw Szkodzinski <astralstorm at gorzow.mm.pl> Samuel Tardieu <sam at rfc1149.net> K Thananchayan <thananck at yahoo.com> Andrew Thompson <andrewkt at aktzero.com> Michael S. Tsirkin <mst at mellanox.co.il> Rafael Villar Burke <pachi at mmn-arquitectos.com> Tristan Wibberley <tristan at wibberley.org> Mark Williamson <mark.williamson at cl.cam.ac.uk>