This is an archive of the discontinued Mercurial Phabricator instance.

encoding: define local identify functions with explicit type comments
ClosedPublic

Authored by durin42 on Nov 6 2019, 5:56 PM.

Details

Summary

This removes some obfuscation as far as pytype is concerned and
corrects many bogus type errors.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

durin42 created this revision.Nov 6 2019, 5:56 PM
indygreg accepted this revision.Nov 7 2019, 3:06 AM
This revision is now accepted and ready to land.Nov 7 2019, 3:06 AM
yuja added a subscriber: yuja.Nov 8 2019, 9:10 AM
  • a/mercurial/encoding.py

+++ b/mercurial/encoding.py
@@ -241,8 +241,15 @@

strfromlocal = unifromlocal
strmethod = unimethod

else:

  • strtolocal = pycompat.identity
  • strfromlocal = pycompat.identity

+
+ def strtolocal(s):
+ # type: (str) -> bytes
+ return s
+
+ def strfromlocal(s):
+ # type: (bytes) -> str
+ return s

It disables the fast path f is identity in pycompat.rapply. I don't
think that matters, but I just noted.