Page MenuHomePhabricator

encoding: define local identify functions with explicit type comments
ClosedPublic

Authored by durin42 on Wed, Nov 6, 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
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

durin42 created this revision.Wed, Nov 6, 5:56 PM
indygreg accepted this revision.Thu, Nov 7, 3:06 AM
This revision is now accepted and ready to land.Thu, Nov 7, 3:06 AM
yuja added a subscriber: yuja.Fri, Nov 8, 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.