[PATCH 5 of 7] typing: suppress error of py2 encoding.strtolocal() and .strfromlocal()

Yuya Nishihara yuya at tcha.org
Sat Nov 16 06:59:41 EST 2019


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1573888179 -32400
#      Sat Nov 16 16:09:39 2019 +0900
# Node ID e4db6b41230a04e20c67d87fc97ff90151369cae
# Parent  e545494cb15eb7191d4b93728648a7d2290b5311
typing: suppress error of py2 encoding.strtolocal() and .strfromlocal()

I don't know how to conditionally get rid of these py2/py3 overloads from
.pyi file. Instead, this patch makes pytype ignore the false-positives:

  line 271, in strtolocal: bad option in return type [bad-return-type]
  Expected: bytes
  Actually returned: str

diff --git a/mercurial/encoding.py b/mercurial/encoding.py
--- a/mercurial/encoding.py
+++ b/mercurial/encoding.py
@@ -268,11 +268,11 @@ else:
 
     def strtolocal(s):
         # type: (str) -> bytes
-        return s
+        return s  # pytype: disable=bad-return-type
 
     def strfromlocal(s):
         # type: (bytes) -> str
-        return s
+        return s  # pytype: disable=bad-return-type
 
     strmethod = pycompat.identity
 


More information about the Mercurial-devel mailing list