( )⚙ D10122 shelve: fix conversion of exceptions to strings flagged by pytype

This is an archive of the discontinued Mercurial Phabricator instance.

shelve: fix conversion of exceptions to strings flagged by pytype
ClosedPublic

Authored by mharbison72 on Mar 6 2021, 7:45 PM.

Details

Summary

I've seen this done several ways and don't know what's correct. But pytype was
unhappy about the previous way:

FAILED: /mnt/c/Users/Matt/hg/tests/.pytype/pyi/mercurial/shelve.pyi
/usr/bin/python3.6 -m pytype.single --imports_info /mnt/c/Users/Matt/hg/tests/.pytype/imports/mercurial.shelve.imports --module-name mercurial.shelve -V 3.6 -o /mnt/c/Users/Matt/hg/tests/.pytype/pyi/mercurial/shelve.pyi --analyze-annotated --nofail --quick /mnt/c/Users/Matt/hg/mercurial/shelve.py
File "/mnt/c/Users/Matt/hg/mercurial/shelve.py", line 244, in _verifyandtransform: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
         Expected: (self, ints: Iterable[int])
  Actually passed: (self, ints: Union[KeyError, TypeError, ValueError])
File "/mnt/c/Users/Matt/hg/mercurial/shelve.py", line 253, in _getversion: Function bytestr.__init__ was called with the wrong arguments [wrong-arg-types]
         Expected: (self, ints: Iterable[int])
  Actually passed: (self, ints: ValueError)
  The following methods aren't implemented on ValueError:
  __iter__

Diff Detail

Repository
rHG Mercurial
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

mharbison72 created this revision.Mar 6 2021, 7:45 PM
This revision was not accepted when it landed; it landed in state Needs Review.
This revision was automatically updated to reflect the committed changes.