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

login
register
mail settings
Submitter Yuya Nishihara
Date Nov. 16, 2019, 11:59 a.m.
Message ID <e4db6b41230a04e20c67.1573905581@mimosa>
Download mbox | patch
Permalink /patch/43298/
State Accepted
Headers show

Comments

Yuya Nishihara - Nov. 16, 2019, 11:59 a.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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

Patch

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