comparison mercurial/encoding.py @ 43681:b65fcccd9100

typing: fix argument type of encoding.tolocal() and .fromutf8b() Fixes various pytype errors.
author Yuya Nishihara <yuya@tcha.org>
date Sat, 16 Nov 2019 15:27:12 +0900
parents 3364a15f61f0
children 83a349aaeba3
comparison
equal deleted inserted replaced
43680:3364a15f61f0 43681:b65fcccd9100
136 >>> assert safelocalstr(b'\\xc3') in {b'\\xc3': 0} 136 >>> assert safelocalstr(b'\\xc3') in {b'\\xc3': 0}
137 """ 137 """
138 138
139 139
140 def tolocal(s): 140 def tolocal(s):
141 # type: (Text) -> bytes 141 # type: (bytes) -> bytes
142 """ 142 """
143 Convert a string from internal UTF-8 to local encoding 143 Convert a string from internal UTF-8 to local encoding
144 144
145 All internal strings should be UTF-8 but some repos before the 145 All internal strings should be UTF-8 but some repos before the
146 implementation of locale support may contain latin1 or possibly 146 implementation of locale support may contain latin1 or possibly
646 r += c 646 r += c
647 return r 647 return r
648 648
649 649
650 def fromutf8b(s): 650 def fromutf8b(s):
651 # type: (Text) -> bytes 651 # type: (bytes) -> bytes
652 '''Given a UTF-8b string, return a local, possibly-binary string. 652 '''Given a UTF-8b string, return a local, possibly-binary string.
653 653
654 return the original binary string. This 654 return the original binary string. This
655 is a round-trip process for strings like filenames, but metadata 655 is a round-trip process for strings like filenames, but metadata
656 that's was passed through tolocal will remain in UTF-8. 656 that's was passed through tolocal will remain in UTF-8.